Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manually trigger Laravel model event

When no data is changed then laravel checks for isDirty and never executed the update query and hence model updated event is not fired. How can we manually trigger an event?

like image 446
Jagadesha NH Avatar asked Oct 22 '25 04:10

Jagadesha NH


1 Answers

To manually trigger an event

$user = User::findOrFail($id);
$user->fill($data);
$user->save();

event('eloquent.updated: App\User', $user);
like image 66
Jagadesha NH Avatar answered Oct 23 '25 18:10

Jagadesha NH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!