Reputation: 2505
I wanted to make my <li>
tag active , for that i wanted to check if $category->id == $product->category_id
if equals then the class would be active otherwise inactive. How do i do it inside blade? I have done the following way.But i couldn't get proper output.
<li class="{!! ($category->id == $product->category_id) ? 'active': '' !!}">
Upvotes: 1
Views: 1593
Reputation: 8877
You're pretty close:
<li class="{{ ($category->id == $product->category_id ? 'active': '') }}">
You need {{
, not {!!
. I also fixed a typo with category_id
.
Upvotes: 2