Problem with logout in laravel system 5.3

1

I have an admin that is already logging in correctly, I have the logout function done but it gives the following error: when I log out it says that there is no column remember_token in my table.

How can I resolve this? Because I created the custom tables.

Controller

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
use DB;
use Auth;
use Redirect;
use Hash;
use Illuminate\Support\Facades\Input;

class LoginController extends Controller
{
    public function showLogin ()
    {
        if (Auth::check()){
            return Redirect::to('/admin');
        }
        return view('admin/login');
    } 

    public function postLogin()
    {
        $username = Input::get('username');
        $passwd   = Input::get('password');

        $user = User::where('username', $username)->first();

        if ($user && Hash::check($passwd, $user->passwd)) {
            Auth::login($user);
            return Redirect::intended('admin');    
        }

        return Redirect::back()->with('error_message', 'Dados Incorrectos')->withInput();
    }

    public function logOut()
    {
        Auth::logout();
        return Redirect::to('admin/login')->with('error_message', 'Logged out correctly');
    }
}
    
asked by anonymous 19.01.2017 / 16:40

2 answers

0

When you create your migrations, you add a column to this table:

...
$table->rememberToken();
...

You can also do this manually by adding the remember_token column to the default value NULL in your table:

ALTER TABLE admins ADD COLUMN remember_token VARCHAR(100) DEFAULT NULL;
    
19.01.2017 / 16:44
1

This happens because you are using a table that is not the default of Laravel 5.3 , it follows the% of creation% for the table.

  

If you want to create the table from scratch.

public function up()
    {
        Schema::create('NOME DA SUA TABELA', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }
  

If you want to edit the existing table.

public function up()
        {
            Schema::table('NOME DA SUA TABELA', function (Blueprint $table) {
                $table->rememberToken();
            });
        }
    
19.01.2017 / 16:45