Do something with record after save

Hi, somehow I did not find a solution for doing something with a record after it was created/updated. Use case: I want to place a checkbox to a resource form. Then when record was created or updated, I want to check if that checkbox was checked and if it was, I want to create a job operation. Example:
public function afterSaveHook(Model $model, array $data)
{
if (isset($data['is_completed']) {
SendCompletedNotification::dispatch($model);
}
}
public function afterSaveHook(Model $model, array $data)
{
if (isset($data['is_completed']) {
SendCompletedNotification::dispatch($model);
}
}
3 Replies
varovas
varovas2mo ago
I don't know if I can get form data in an observer.
LeandroFerreira
LeandroFerreira2mo ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Want results from more Discord servers?
Add your server