I have a table with 3 datetime fields:
1.created_at
(generated and handled by Laravel),
2.updated_at
(generated and handled by Laravel),
3.custom_date
(created by mine, it will be changed every time created_at
or updated_at
is changed).
I would that every time that a new record is created or the first two fields are changed, the custom_date
is updated using a callback.
How can achieve this using Eloquent in Laravel 5.7?
I have already tried using a mutator but I would avoid it because I would update the field every time created_at
or updated_at
are changed.