Answer the question
In order to leave comments, you need to log in
How to catch Laravel exception?
Hello!
I can’t understand why try catch doesn’t catch the exception, maybe I don’t understand correctly and laravel doesn’t throw an exception of the ModelNotFound type in my case.
// id Компании (компания с таким id есть в базе)
// user_id - Это id пользователя который добавил компанию
// Я намеренно у запрашиваемой модели компании в базе поменял user_id на id другого пользователя
try {
Company::where('id', $id)
->where('user_id', Auth::id())
->get();
} catch (Exception $exception){
//Тут действия по обработке
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question