我想为迁移中的列设置默认日期时间 + 现在之后 10 分钟,如下所示:
$table->dateTime('expire_at')->useCurrent() + 10 minutes;
作为替代方法,您可以尝试在模型中boot
方法中设置值:
protected static function boot()
{
parent::boot();
static::creating(function ($query) {
$query->expire_at = Carbon::now()->addMinutes(10);
});
}