I'm currently working on a Laravel application which is using Model events to perform data validation / synchronization in the database.
I've a table which contains important data. This table is updated on different Model updates. I use model events to handle that. It works on Model properties example :
<?php
Product::saved(function (Product $p) {
$dirty = collect($p->getDirty());
if ($dirty->has('ugr') || $dirty->has('ra')) {
//Do some stuff here
}
});
With that kind of logic I can restrict my "stuff" execution on specific model property update.
How can I make that kind of check on Product relations ?
I've a ManyToMany relationships accessible through the applications methods on Product, how can I know if the linked application list has changed since model loading ?
Thanks for your help !
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire