Don't do this kind of logic in template.
Blade if statement
Hi All,
I'm attempting to compile the following in a partial to a blade template without much success, appears if I add an || (OR) conditional into the if statement it will not work correctly, am I missing something? There was not an example of multiple conditionals in the documentation so many i'm doing something that isn't supported?
@if(Request::path() != '/' || Request::path() != 'another/url')
...some code
@endif
Thanks
In Controller:
$isSomeCondition = Request::path() != '/' || Request::path() != 'another/url'; // import request or use global namespace with \
Then pass variable to the view...
In view:
@if($isSomeCondition)
// do the stuff
@endif
First of all you extracted app logic form tempalte, and in template condition is more descriptive. If controller is full of logic you can extract this to separate Class or make a global function... but it is a good first step.
Please or to participate in this conversation.