Route::ressource
is a very convenient method that handles many conventions on the fly like the controller methods names, the URI, the route name, and the HTTP verb. But you may often find yourself
chainning Route::ressource
with only
or except
for various reasons:
- Altering the ressource controller methods signatures.
- Using different
middlewares
on resouce routes.
In the case you find yourself using Route::ressource
for only one or two methods, this package may come in handy, to offer what may seem as a cleaner syntax.
composer require elaborate-code/laravel-resource-routes
ResourceRoute::index('resources', ResourceController::class);
// Equivelent to:
// Route::ressource('resources', ResourceController::class)->only('index');
ResourceRoute::create('resources', ResourceController::class);
ResourceRoute::store('resources', ResourceController::class);
// Equivelent to:
// Route::ressource('resources', ResourceController::class)->only(['create', 'store']);
ResourceRoute::show('resources', ResourceController::class);
Route::middleware('can:update')->group(function () {
ResourceRoute::edit('resources', ResourceController::class);
ResourceRoute::update('resources', ResourceController::class);
});
ResourceRoute::destroy('resources', ResourceController::class);
vendor/bin/pest
The MIT License (MIT). Please see License File for more information.