Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column not found: 1054 Unknown column 'remember_token' in 'field list'?

Im trying to do Auth:logout();, but im getting this error. Do i really need this column or i can avoid that?

Route::get('/logout', 'MainController@logout');

  public function logout(){
      Auth::logout();

      return response()->json([
        'isLoggedIn' => false
        ]);
    }
like image 736
None Avatar asked Mar 18 '17 11:03

None


2 Answers

Looks like you've deleted the remember_token from the users table. Laravel uses this field by default, so you can just add the field back to the table:

$table->rememberToken();

Of course you could override some of Laravel methods to disable this functionality, but I wouldn't recommend that.

like image 142
Alexey Mezenin Avatar answered Sep 24 '22 14:09

Alexey Mezenin


You could avoid that by using this on your User Model.

 /**
* Overrides the method to ignore the remember token.
*/
public function setAttribute($key, $value)
{
$isRememberTokenAttribute = $key == $this->getRememberTokenName();
if (!$isRememberTokenAttribute)
{
  parent::setAttribute($key, $value);
}
}
like image 45
a3rxander Avatar answered Sep 25 '22 14:09

a3rxander