我想创建一个时间戳列,其默认值为CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP使用Laravel架构生成器/迁移.我已多次浏览Laravel文档,但我看不出如何将其作为timestamp列的默认值.
该timestamps()函数0000-00-00 00:00为它所做的两列提供默认值.
我有一个问题updated_at,created_at在Laravel 5中的字段.
这是我的迁移:
Schema::create('lots', function (Blueprint $table) {
$table->increments('id');
$table->integer('lot');
$table->integer('is_active');
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
但是,当我插入一些数据到这个表中,updated_at并且created_at字段为空.如何使用当前时间戳自动完成它们?
我插入这样的数据:
\DB::table('admin_lots')->insert([
'lot' => $request->cycle_lot,
'is_active' => '1',
]);
Run Code Online (Sandbox Code Playgroud)
谢谢.