Error message:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR) Class '\User' not found Controller edit from scotch.io
public function doLogin() {
$rule = array(
'username' => 'required|min:3',
'password' => 'required|alphaNum|min:3'
);
$validator = Validator::make(Input::all(), $rule);
if($validator->fails()){
return Redirect::to('login')
->withErrors($validator)
->withInput(Input::except('password'));
}else{
$userdata = array(
'username' => Input::get('username'),
'password' => Input::get('password')
);
}
if(Auth::attempt($userdata)){
echo 'SUCCESS!';
}else{
return Redirect::to('login');
}
}
Since the line “Auth::attempt($userdata)” would call the model named “User” and interact with the table named “users” by default. If you do not want to use table users or use another model name, you can go to edit the auth config file at:
Laravel 4 :
app/config/auth.phpLaravel 5:
config/auth.php
And change the value of model and table:
'model' => 'User',For example, to
'table' => 'users',
'model' => 'Admin',
'table' => 'admins_table',
Reference:
Controller code :
https://scotch.io/tutorials/simple-and-easy-laravel-login-authentication
Solution:
http://stackoverflow.com/questions/15801314/class-user-not-found-in-laravel
No comments :
Post a Comment