我在Laravel 5.2中的特定模型中有一些额外的日期:'deleted_at', 'due_at', 'reminded_at', 'paid_at'
,以及时间戳'created_at', 'updated_at'
。所有这些都是null
能够。
TLDR编辑:当我$object->save()
所有对象都设置了'created_at', 'updated_at', 'due_at'
,当我尝试将'paid_at'
设置为now
时,它不仅会更改paid_at,还会更改所有非{ {1}}字段null
(编辑:除了created_at)
now
我运行之前的一行结果:
public function postPaid($id)
{
$invoice = Invoice::findOrFail($id);
$invoice->paid_at = Carbon::now();
$invoice->save();
return back();
}
运行后的一行结果:
| due_at | reminded_at | paid_at | created_at | updated_at | deleted_at |
|-------------------------------------------------------------------------------------|
| 2016-02-10 07:29:41 |NULL | NULL | 2016-01-23 16:31:22 | 2016-01-23 16:31:22 | NULL |
所以它设置了paid_at,但除了created_at之外,所有其他日期也更改为| due_at | reminded_at | paid_at | created_at | updated_at | deleted_at |
|-------------------------------------------------------------------------------------|
| 2016-01-23 22:19:00 | NULL | 2016-01-23 22:19:00 | 2016-01-23 16:31:22 | 2016-01-23 22:19:00 | NULL |