Model
...
protected $dates = [
'closed_at',
];
...
table info
...
$table->timestamp('closed_at');
...
Why the closed_at
field is automatically updated when I modify the model ?
Model
...
protected $dates = [
'closed_at',
];
...
table info
...
$table->timestamp('closed_at');
...
Why the closed_at
field is automatically updated when I modify the model ?
It will not take automatically. You have to insert it.
$post= Post::find(1);
$post->title= 'new title';
$post->closed_at=now();
$post->save();
For more information see documentation Or You can check stackoverflow answer for similar question.
This is because $table->timestamp('field')
is automatically maintained by mysql.
Like this DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP