阅读(3206) (0)

Laravel 8 数据库

2021-06-25 09:32:01 更新

使用 database 作为 Session 驱动时,你需要创建一张包含 Session 各项数据的表。以下是使用 Schema 建表的例子:

Schema::create('sessions', function ($table) {
    $table->string('id')->unique();
    $table->foreignId('user_id')->nullable();
    $table->string('ip_address', 45)->nullable();
    $table->text('user_agent')->nullable();
    $table->text('payload');
    $table->integer('last_activity');
});

你可以使用 Artisan 命令 session:table 来生成此迁移:

php artisan session:table

php artisan migrate