permafrost-dev / laravel-current-route
This package is abandoned and no longer maintained.
No replacement package was suggested.
Helpers for retrieving information about the current route
1.0.5
2020-07-22 15:50 UTC
Requires
- php: ^7.2.5
- illuminate/routing: ^7.0
- laravel/framework: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- nunomaduro/phpinsights: ^1.14
- orchestra/testbench: ^5.3
- phpunit/phpunit: ^8.0
README
Laravel Current Route
Helper functions and class to retrieve information about the current route in Laravel.
Installation
You can install the package via composer:
composer require permafrost-dev/laravel-current-route
Helper Functions
// Return a Laravel Route object for the current route. function current_route(); // Return a class containing information about the current route. function current_route_info(); // Return the action for the current route. function current_route_action(); // Return true if one of the specified wildcard patterns matches the name of the current route. function current_route_matches($patterns); // Return the name for the current route. function current_route_name(); // Returns true if $name matches the name of the current route. function current_route_named($name);
Usage
WIP
Examples
Use current_route_named()
to generate conditional css classes in a blade template:
<a class="{{ current_route_named('dashboard') ? 'active' : 'inactive' }}" href="{{ route('dashboard') }}">Dashboard </a>
Testing
$ vendor/bin/phpunit
License
The MIT License (MIT). Please see the License File for more information.