active
active copied to clipboard
Certain routes do not work
I am using lumen framework and I noticed multiple word named routes do not work with this package.
<a href="{{route('article.create')}}" class="{{active(['article.create'], 'active')}}">
New Article
</a>
$router->get('/article/create', [
'as' => 'article.create',
'uses' => 'ArticleController@create'
]);
When I invoke is_active('article.create') in ArticleController@create it returns false. If I change the route to just "/article" and change the name from "article.create" to "article", it works.
The same problem occurs on "/".
Thanks for reporting this. Just to clarify, you have a route named article.create and is_active won’t recognise it? If you could describe the exact problem you are seeing on ‘/‘ too.
Lumen uses a different router to Laravel but I would have through the route matching worked the same. Once I have your two broken examples I’ll try find out what is going on.
Yes article.create does not seem to get recognized by is_active (it returns false).
As for "/":
<li><a href="{{route('home')}}" class="{{active(['home'], 'active')}}">Home</a></li>
$router->get('/', [
'as' => 'home',
'uses' => 'HomePageController@index'
]);
I named it "home" and the route works (pages switch on click) but is_active() returns false. The same happens when I change the name of the route to an empty string ""
<li><a href="{{route('')}}" class="{{active([''], 'active')}}">Home</a></li>
$router->get('/', [
'as' => '',
'uses' => 'HomePageController@index'
]);
Single word routes work though. For example a route /foo named "foo" works perfectly