dimanche 26 mai 2019

Check if an attribute has changed in Laravel 5.5 model events

I've seen that there is a function called wasChanged() where you can check if an attribute was changed on an update. Not is dirty, but was changed and persisted

However I'm trying to check this inside my model events boot function:

public static function boot()
{
    parent::boot();

    self::updated(function($appointment){

        if($appointment->wasChanged('appointment_date')) {
         // do something
        }

    });
}

This never works for me. Any ideas how I can check this?

the isDirty function has different behavior as that is used to check if an attribute was submitted in the request.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2WqNper
via IFTTT

Aucun commentaire:

Enregistrer un commentaire