0

I am using Laravel 9, updating/upated boot method not working. When I use deleting then updating/upated boot method running to update delete_at and deleted_by field value but when I try to update any thing doesn't work.

self::updating(function ($model) {
   $user = Auth::user();
   $model->updated_by = $user->id;
});
$data = array(
    'title'         =>  $request->title,
    'account_type'  =>  $request->account_type
);
Head::find($request->head_id)->update($data);
Arsalan Ahmed
  • 188
  • 1
  • 12

1 Answers1

0

You can try this:

self::updating(function ($model) {
    $user = Auth::user();
    $model->updated_by = $user->id;
    $model->save();
});

The save() function is required to save record.

Hamid Raza
  • 28
  • 1
  • 6