letrunghieu / active

The helper class for Laravel applications to get active class base on current route
https://www.hieule.info/tag/laravel-active/
MIT License
414 stars 83 forks source link

Route parameters? #21

Closed m1r0 closed 8 years ago

m1r0 commented 9 years ago

I think it would be a good idea to include the route parameters and not only the route name.

Lets say we need to set an active class for the route admin/product-types/{product_types}/categories.

We can do something like (not a very good example but hopefully you get the point): Active::route(['admin.product-types.categories.index' => [$product_type->id]])

mozmorris commented 9 years ago

@m1r0 Agreed.

For now, this should do what you want:

Active::pattern(
    ltrim(route('pages.show', $page->slug, false), '/')
);
letrunghieu commented 9 years ago

I released a minor update for the 2.x version. Your can see the release note.

In your case, I suggest using this expression to set the active class when the current route is admin.product-types.categories.index and the value of the product_types parameter is 1:

Active::routeParam('admin.product-types.categories.index', ['product_types' => 1])

I also rewritten the package and release it as a new major version, the 3.0.0. You can see the new documentation with new API in the master branch.

m1r0 commented 8 years ago

@letrunghieu Thanks.