Reputation: 2021
I have a route declared as
Route::resource('users', 'UserController');
now, I am creating a dynamic menu.. but using
<li {{(Route::is('users/*'))? ' class="active"' : '';}}><a href="{{ URL::action('UserController@index') }}">Users</a></li>
doesn't return true for any case of the /users (/users, /users/{id}, etc..)
Now, what could I have missed? How do I make this work?
thanks!
Upvotes: 1
Views: 4008
Reputation: 53
If you are using controllers try this :
{{ Route::is('users.*') ? 'active': null }}
Works for me in Laravel 5
Upvotes: 0
Reputation: 3959
are you sure the right method to use is Route::is? I can't see this mentioned anywhere in the code. It's quite possibly you're looking for Request::is, ie:
Request::is('users/[a-z]*')
This deeper down utilizes the Str::is() function, which takes the same argument, and I'm not sure if * applies there, which is why I've given the full regular expression in this example. You can try with just using * instead of the [a-z] match as well, and see if that works.
Upvotes: 6