Package Data | |
---|---|
Maintainer Username: | Rukhsar |
Maintainer Contact: | rukhsar.man@gmail.com (Rukhsar Manzoor) |
Package Create Date: | 2016-12-05 |
Package Last Update: | 2018-04-13 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-10 15:06:14 |
Package Statistics | |
---|---|
Total Downloads: | 3,220 |
Monthly Downloads: | 7 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 2 |
Total Open Issues: | 1 |
Helper class for Laravel applications to get active class base on current route name.
Install using composer
composer require rukhsar/laravel-active-route
Add below line to your service providers array in config/app.php
Rukhsar\ActiveRoute\ActiveRouteServiceProvider::class,
Add below line to your aliases array in config/app.php
'Active' => Rukhsar\ActiveRoute\Facades\Active::class,
Publish config file using
php artisan vendor:publish --provider="Rukhsar\ActiveRoute\ActiveRouteServiceProvider" --tag="config"
In config/activeroute.php
you can modify the css active class which notmally active
if you are using bootsrap.
return [
// The default css class value if the request match given route name
'class' => 'active',
];
You can use this package in different ways like...
Active::route('route.name'); // Facade example
app('active')->route('route.name'); // Application container example
active_route('route.name'); // Helper function
// Wildcard exmaples
Active::route('route.name.*');
active_route('route.name.*');
// Multiple Routes
Active::route(['route.name1.*', 'route.name2.*']);
active_route(['route.name1.*', 'route.name2.*']);
You can also use custom blade directive in your blade templates.
@ifActiveRoute('route.name')
<p>True</p>
@else
<p>False</p>
@endif
<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.