我的代码有问题。我正在创建管理员注册,我无法使用eloquent访问我的模型。我有我的客户用户注册,我遵循相同的格式,但我不能在我的管理部分。
这是我的代码:
路线
Route::model('administrator','Administrator');
Route::get('/flaxadmin', 'AdministratorsController@index');
Route::get('/admin_login', 'AdministratorsController@login');
Route::get('/admin_register', 'AdministratorsController@register');
Route::get('/admin_dashboard', 'AdministratorsController@dashboard');
Route::post('/admin_handle_register', function()
{
$rules = array(
'admin_username' => 'required|min:5|max:15',
'admin_lastname' => 'required|min:2|max:20',
'admin_firstname' => 'required|max:20',
'admin_password' => 'required|min:8|max:16',
'admin_cpassword' => 'required|same:admin_password'
);
$validate_admin_register = Validator::make(Input::all(), $rules);
if($validate_admin_register->fails()) {
$messages = $validate_admin_register->messages();
return Redirect::to('admin_register')->withErrors($messages)->withInput(Input::except('password','cpassword'));
} else {
$admin = new Administrator;
$admin->username = Input::get('username');
$admin->lastname = Input::get('lastname');
$admin->firstname = Input::get('firstname');
$admin->password = Hash::make(Input::get('password'));
$admin->save();
Session::flash('success_notification','Success: The admin account has been successfully created!');
return Redirect::action('AdministratorsController@index');
}
});
我的模特
<?php
class Admninistrator extends Eloquent {
}
?>
这是我的错误消息
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Class 'Administrator' not found
我不知道我的错误在哪里。你可以帮帮我吗?
答案 0 :(得分:2)
您的班级名称为Admninistrator
而非Administrator
更改这些行
class Admninistrator extends Eloquent {
}
到这一行
class Administrator extends Eloquent {
}