我遇到了这个错误,很奇怪,我到处检查,我认为代码很好。 问题是我想要控制器中我的模型中的实例,但它给出了上面的错误 错误图像 我将把代码放在下面。 这是控制器
<?php namespace AppControllersUser;
use AppControllersBaseController;
use AppModelsUserModel;
class Users extends BaseController{
public function index(){
echo view('includes/header');
echo view('user/index');
echo view('includes/footer');
}
public function login(){
}
public function register(){
$model = new UserModel();
if($this->request->getPost()){
return "f";
}
echo view('includes/header');
echo view('user/register');
echo view('includes/footer');
}
}
这是模型
<?php
namespace AppModels;
use CodeigniterModel;
class UserModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useSoftDeletes = true;
protected $allowedFields = ['email', 'username', 'password'];
protected $useTimestamps = true;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
protected $validationRules = [
'email' => 'required|valid_email',
'username' => 'required|min_length[2]|max_length[10]',
'password' => 'required|min_length[8]|max_length[20]'
];
protected $validationMessages = [
'email' => [
'required' => 'This field is required',
'valid_email' => 'email is not valid make sure you wrote it right'
],
'username' => [
'required' => 'This field is required',
'min_length' => 'the min username is 2',
'max_length' => 'the max username is 10'
],
'password' => [
'required' => 'This field is required',
'min_length' => 'the min pasword is 8',
'max_length' => 'the max pasword is 20'
]
];
// protected $skipValidation = false;
}
请帮忙我被困在那里:(
..............................
您使用的文件名为:
use Codeigniter/Model
将其替换为 :
use CodeIgniter/Model