Answer the question
In order to leave comments, you need to log in
How to set default link in Laravel 5 if not found?
Greetings.
There is a model, the model has a connection.
In the template, I pull the method from the associated model: $model->relation->method()
If there is no connection, which is possible, a logical error is thrown out that `method()` does not exist.
How to resolve this optimally, so as not to check for the existence of a connection everywhere in the code? How to slip him a default model?
Answer the question
In order to leave comments, you need to log in
And how do you assign a default to different links? you will have different models and for each you still need to write conditionally try. They still have to be checked.
If you need to check in View, then like this:
@if (isset($t->callStatusColor)) {{$t->callStatusColor}} @endif
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question