teguh_rijanandi's avatar

'remember_token' doesn't have a default value

whats should i do?? In users table i have 5 column (Name,email,password,update_at,created_at), but in regsitration form i dont have inputs with remember token name??

Illuminate\Database\QueryException thrown with message "SQLSTATE[HY000]: General error: 1364 Field 'remember_token' doesn't have a default value (SQL: insert into users (name, email, password, updated_at, created_at) values (Teguh Rijanandi, hisaon4@gmail.com, $2y$10$hsUSJCEoaKwiBSSm2adNr.YduD8suMeQg0yMyMZ/65yItvnDiqhVS, 2018-06-02 21:58:14, 2018-06-02 21:58:14))"

0 likes
4 replies
Cronix's avatar

You wouldn't have a form field where the user enters the remember_token value...that's done automatically with the password_reset functionality with laravels built-in auth.

So, just add a remember_token field to the users table? The default migration creates one withvarchar(100) with a default of null

php artisan make:migration add_remember_token_to_users_table --table=users

Then edit the migration, and

public function up()
{
    Schema::table('users', function (Blueprint $table) {
        $table->string('remember_token', 100)->nullable();
    });
}

public function down()
{
    Schema::table('users', function (Blueprint $table) {
        $table->dropColumn('remember_token');
    });
}

and run the migrations php artisan migrate

jlrdw's avatar

What does the docs say about a remember token?

If you are using the built-in LoginController that is shipped with Laravel, the proper logic to "remember" users is already implemented by the traits used by the controller.

https://laravel.com/docs/5.6/authentication#remembering-users

If following the docs didn't work create an issue on GitHub.

Cronix's avatar

Or maybe he's not using "the built-in LoginController"...or maybe he is and created his tables manually, etc...

Please or to participate in this conversation.