vdauchy/laravel-routing-extender is a Laravel package.
It currently has 0 GitHub stars and 66 downloads on Packagist (latest version 0.2.0).
Install it with composer require vdauchy/laravel-routing-extender.
Discover more Laravel packages by vdauchy
or browse all Laravel packages to compare alternatives.
Last updated
Laravel Routing Extender
This package extends Laravel's core routing services.
optionalParameterGroup as:// In Routes/web.php:
Route::optionalParameterGroup('hreflang', '^[a-z]{2}(?:\-[a-z]{2})?$', ['as' => 'Hreflang::'], function () {
Route::get('home')->name('home');
});
// In YourCode.php:
route('Hreflang::home', []); // Will return `/home`
route('Hreflang::home', ['hreflang' => 'en-us']); // Will return `/en-us/home`
customRouteResolver as.// In xxxProvider.php
URL::macro('customRouteResolver', function($name, $parameters, $absolute): ?\Illuminate\Routing\Route {
if ($name instanceof CustomClassA::class) {
return $name->getRoute();
}
if ($name instanceof CustomClassB::class) {
return $name->generateRoute();
}
return null;
});
// In YourCode.php:
route($instanceClassA); // Will generate the url from the Route object return by `$instanceClassA->getRoute()`
route($instanceClassB); // Will generate the url from the Route object return by `$instanceClassB->generateRoute()`