I am currently generating my application urls using {{action('Namespace\Class@method')}}
. How would I check if the current page request maps to that current action Namespace\Class@method
?
I would like to do something like:
<a href="{{action('Namespace\Class@method')}}
@if (currentAction('Namespace\Class@method'))
class="active"
@endif
>Some link</a>
How would I achieve this in Laravel 5?
This is how I do it without any named routes
<a class="{{ str_contains(request()->url(), '/some-page') ? 'active' : '' }}" href="/some-page">Some Page</a>
This is not a perfect solution but it works for most cases
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With