Laravelfilament 有 afterCreate 函数,该函数会在数据存储到数据库后触发
protected function afterCreate(): void
{
// Runs after the form fields are saved to the database.
}
问题是,如何获取“存储”的数据?我需要为其保存一个日志(在不同的表中),该日志需要
stored
数据的 id
protected function afterCreate()
{
$taskDetail = $this->record;
Task::create([
'taskName' => $taskDetail->taskName,
'alias' => $taskDetail->alias,
'description' => $taskDetail->description,
'status_id' => $taskDetail->status_id,
'piority_id' => $taskDetail->piority_id,
'project_id' => $taskDetail->project_id,
'task_type_id' => $taskDetail->task_type_id,
'originalEstimate' => $taskDetail->originalEstimate,
'timeTrackingSpent' => $taskDetail->timeTrackingSpent,
'timeTrackingRemaining' => $taskDetail->timeTrackingRemaining,
'listUserAssign' => json_encode($taskDetail->listUserAssign),
]);
}
我尝试使用 afterCreate 但它不起作用