'Laravel logout remember token error

This time I'm trying to do logout user... I'm pretty sure that my routing and controllers are good, but I don't know why I have error looks like this ( of course when I'm trying to logout ):

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'remember_token' in 'field list' 

This is my method in controller :

public function logout()
{
    Auth::logout();
    return redirect('/');
}

My logout is a link in view... What is wrong?



Solution 1:[1]

I'm using Laravel 5.5 and reading about The User Provider Contract, I saw something is also the answer to another question here in StackOverflow:

As User class inherit from Authenticatable, The Authenticatable class uses the AuthenticatableContract, and implements the methods for getting and setting Tokens for users.

So, a simple solution is to overwrite (or to implement) these methods in your User class (or equivalent):

public function getRememberToken()
{
    return $this->token;
}

public function setRememberToken($value)
{
    $this->token = $value;
}

public function getRememberTokenName()
{
    return 'token';
}

You can replace the 'token' and use whatever word that you want.

Solution 2:[2]

Add functions on Auth/LoginController:

function get_guard(){
        if(Auth::guard('web')->check()){
            return "web";
        }
        elseif(Auth::guard('manager')->check()){
            return "manager";
        }
        elseif(Auth::guard('client')->check()){
            return "client";
        }
        return "web";
    }

    public function logout(){
        $guard = $this->get_guard();
        switch ($guard) {
            case 'admin': Auth::guard('admin')->logout(); break;
            case 'web' : Auth::guard('web')->logout(); break;
            default : Auth::guard('web')->logout(); break;
        }
        return redirect()->guest(route("login"));
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Saulo Gomes
Solution 2 Max Sarat