Laravel - How to a try/catch in blade view? -


i create way compile in view, try/catch. how can in laravel?

example:

@try <div class="laravel test">     {{ $user->name }} </div> @catch(exception $e)     {{ $e->getmessage() }} @endtry 

you should not have try/catch blocks in view. view that: representation of data. means should not doing logic (such exception handling). belongs in controller, once you’ve fetched data model(s).

if you’re wanting display default value in case variable undefined, can use or keyword:

{{ $user->name or 'name not set' }} 

Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -