mardi 22 décembre 2020

Initialization model inside custom request

There is a model event. I wanna update it. The custom request is used for validation, but have several problems. Every event has two user's relations - client and executor. As an example, I wanna change the event time. That time should be after now and should be free in the executor. The first validation rule is simple, but for the second I have to initialize the event model in custom request, retrieve the executor and his free time. Of course, I can do something like that

$event = Event::find($id);
$executor = $event->executor;

But is it good way to process validation? Do not think so. What the better way to validate that data?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire