Laravel Session Table Adds Additional Column

I want to add an extra column user_idto the table session.

The reason is that at some point there is a spammer to sign a fake account, as soon as I know that the user is a spammer, I want to register the user by deleting the session record.

Can this be achieved?

+3
source share
1 answer

This is the session migration scheme:

Schema::create('sessions', function($table)
{
    $table->string('id')->unique();
    $table->text('payload');
    $table->integer('last_activity');
    $table->integer('user_id')->unsigned(); //// ADD IT!
});

You can add any column that you like on it, Laravel will not mind.

Or you can create a new migration and add it to this table.

$table->integer('user_id')->unsigned();

You can create a model for it:

class SessionModel extends Eloquent {

}

And do whatever you need:

$session = SessionModel::find(Session::getId());
$session->user_id = 1;
$session->save();

, Laravel , , , Laravel, .

+2

Source: https://habr.com/ru/post/1569426/


All Articles