如果用戶模型上沒有softdelete屬性,它就會工作。這裏是我的代碼:如果用戶具有softdelete屬性,則Laravel 5.1 Auth :: attempt()不起作用
用戶模式:
.....
use Authenticatable, Authorizable, CanResetPassword, SoftDeletes;
protected $dates = ['deleted_at'];
protected $softDelete = true;
.....
AuthController:
........
$userdata = ['email' => Input::get('email'), 'password' => Input::get('password'), 'active' => 1];
$authRemember = (Input::get('auth_remember'))? true : false;
// if (Auth::validate($userdata)) {
if (Auth::attempt($userdata, $authRemember)) {
echo 'success';
}else{
echo 'failed';
}
// }else{
// echo 'failed';
// }
.....
我已經設置deleted_at TIMESTAMP和積極TINYINT到我的用戶表。 任何幫助,將不勝感激。
解決 後,我設置的默認值設置爲NULL的deleted_at
列它的工作,並刪除'active' => 1
從上面
嘗試'protected $ softDelete = true;' – aldrin27
@ aldrin27已經試圖添加這些代碼但仍然沒有運氣 – arhakim
因此它總是返回false? – aldrin27