reikyoushin
reikyoushin

Reputation: 2021

Laravel 4 dynamic menu: "Route::is('users/*')" not working

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

Answers (2)

Ali Veseli
Ali Veseli

Reputation: 53

If you are using controllers try this :

{{ Route::is('users.*') ? 'active': null }}

Works for me in Laravel 5

Upvotes: 0

Oddman
Oddman

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

Related Questions