Package Data | |
---|---|
Maintainer Username: | angelside |
Maintainer Contact: | package@juysoft.com (Juy Software) |
Package Create Date: | 2016-01-12 |
Package Last Update: | 2020-02-02 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:06:34 |
Package Statistics | |
---|---|
Total Downloads: | 3,058 |
Monthly Downloads: | 4 |
Daily Downloads: | 0 |
Total Stars: | 5 |
Total Watchers: | 3 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Helper class for Laravel applications to get active class base on current route name (It's only detect "route name, this is enough for us.").
➜ composer require juy/active-menu
Manual install (alternative)
Simply add the following to the "require" section of your composer.json file, and run
composer update
command.
"juy/active-menu": "^1.1"
➜ composer remove juy/active-menu
Append this line to your service providers array in config/app.php
.
Juy\ActiveMenu\ServiceProvider::class,
Publish config file.
➜ php artisan vendor:publish --provider="Juy\ActiveMenu\ServiceProvider" --tag="config"
You can modify css active class with custom one (default is 'active') in config/activemenu.php
(after publish).
return [
// The default css class value if the request match given route name
'class' => 'active',
];
Alias/Facade
Active::route('route.name');
Application container
app('active')->route('route.name');
Helper function
active_route('route.name');
Wildcard samples
Active::route('route.name.*');
active_route('route.name.*');
Multi route with wilcard
Active::route(['route.name1.*', 'route.name2.*']);
active_route(['route.name1.*', 'route.name2.*']);
Custom blade directive
@ifActiveRoute('route.name')
<p>Foo</p>
@else
<p>Bar</p>
@endif
Real life usage
<li class="item {{ active_route('admin.index') }}">
<a href="admin/index">Dashboard</a>
</li>
This project is open-sourced software licensed under the MIT License.