沒有發現我不斷收到類「用戶」在Laravel
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', '[email protected]');
Route::filter('auth', function()
{
if (Auth::guest()) return Redirect::to('login');
});
我用作爲我的身份驗證驅動程序雄辯。我嘗試將其更改爲Fluent,但在單擊登錄按鈕後,它會在else語句中顯示此行return Redirect::to('login')->with('login_errors', true);
發出的登錄錯誤。
使用Eloquent時,'User'類有什麼問題?
你的例子。我沒有看到a:'class User {...}'所以它沒有定義 – 2013-04-04 02:00:39
的確,'User'應該是一個模型。請確認您的'models'文件夾中有'user.php'文件。 – 2013-04-04 04:41:47