S
S
Sergey Krivosheev2018-07-29 21:50:38
Laravel
Sergey Krivosheev, 2018-07-29 21:50:38

How to find model instance in laravel eloquent if get returned 0 records?

Good afternoon.
It is necessary to find out the model instance after the selection if zero records were returned according to the conditions.
If at least 1 entry is returned, then you can easily take the class of the first value from the list. But if the selection did not return a single record, then it is impossible to understand which model was requested. Is there a possibility to do this? Maybe eloqent has some kind of dataProvider?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor, 2018-07-29
@v_decadence

get_class($query->getModel())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question