0
votes

I'm using a Backpack for Laravel CRUD controller and I'm trying to figure out if there's an efficient way to tell if a Model has been updated without loading both the current model and the updated model and then comparing attribute values.

1
The simplest way might be to use Laravel's model observer functionality. Or, you could override the model's save method and use the isDirty('columnName') method to inspect changes as described here stackoverflow.com/questions/28866500/… - Wesley Smith

1 Answers

0
votes

I ended up following the suggestion in the comment and overrode the save() method on my model as such.

public function save(array $options = [])
{

     // Update the mode accordingly and perform any 
     // other actions you need to prior to saving here.

     $saved = parent::save($options);
     return $saved;
 }