B
B
Berkutman2020-07-24 10:58:42
Laravel
Berkutman, 2020-07-24 10:58:42

Laravel session storage in db?

I want to store the session in the database, in the migration file I specify

Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->unique();
$table->foreignId('account_id ')->nullable();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->text('payload ');
$table->integer('last_activity');
});
After that, an error on the site, they say, cannot find the user_id field, because it was the default in the migration file. I need to change this field. Where it needs to be specified so that it perceives the column name as account_id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2020-07-24
@Berkutman

In models, in the definition of relationships, specify andbelongsTo('App\User', 'account_id');->hasMany('App\Session', 'account_id');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question