我想自定義Laravel的模型類來記錄一些其他的事情(例如誰創建/更新/刪除該行中的DBLaravel:自定義模型類
我看到這個模型類的582-。 587
// First we need to create a fresh query instance and touch the creation and
// update timestamp on the model which are maintained by us for developer
// convenience. Then we will just continue saving the model instances.
if ($this->usesTimestamps()) {
$this->updateTimestamps();
}
使用這個(問題/ HasTimestamps.php 32-48):
/**
* Update the creation and update timestamps.
*
* @return void
*/
protected function updateTimestamps()
{
$time = $this->freshTimestamp();
if (! $this->isDirty(static::UPDATED_AT)) {
$this->setUpdatedAt($time);
}
if (! $this->exists && ! $this->isDirty(static::CREATED_AT)) {
$this->setCreatedAt($time);
}
}
我的問題:如何重寫也記錄了 「誰」,而不在供應商文件夾修修補補? (誰來fr om Auth::user()->id
)
謝謝,它的工作就像一個魅力:) – Feralheart