我不断得到
Unhandled Exception
Message:
Class 'User' not found
Location:
C:\wamp\www\laravel\laravel\auth\drivers\eloquent.php on line 70
当我登录用户时。我认为eloquent.php 没有任何问题。请看一下我的登录控制器:
class Login_Controller extends Base_Controller {
public $restful = true;
public function get_index(){
return View::make('login');
}
public function post_index(){
$username = Input::get('username');
$password = Input::get('password');
$user_details = array('username' => $username, 'password' => $password);
if ( Auth::attempt($user_details) )
{
return Redirect::to('home.index');
}
else
{
return Redirect::to('login')
->with('login_errors', true);
}
}
}
这是登录视图:
{{ Form::open('login') }}
<!-- username field -->
<p>{{ Form::label('username', 'Username') }}</p>
<p>{{ Form::text('username') }}</p>
<!-- password field -->
<p>{{ Form::label('password', 'Password') }}</p>
<p>{{ Form::password('password') }}</p>
<!-- submit button -->
<p>{{ Form::submit('Login', array('class' => 'btn btn-primary')) }}</p>
{{ Form::close() }}
和routes.php:
<?php
Route::controller(Controller::detect()); // This line will map all our requests to all the controllers. If the controller or actions don’t exist, the system will return a 404 response.
Route::get('about', 'home@about');
Route::filter('auth', function()
{
if (Auth::guest()) return Redirect::to('login');
});
我使用 Eloquent 作为我的身份验证驱动程序。我尝试将其更改为 Fluent,但是在单击登录按钮后,它会return Redirect::to('login')->with('login_errors', true);
在 else 语句中显示此行所产生的登录错误。
使用 Eloquent 时“用户”类有什么问题?