elaborate-code / laravel-resource-routes
A complementary Route Facade with methods to register resource routes
Requires
- php: ^8.1
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2023-08-13 14:29:43 UTC
README
⚠️Do not use this library! If you like the idea just copy the code from /src/ResourceRoute.php. You do not need to rely on me maintaining a small syntactic sugar to keep your product up and running.
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.
Installation
composer require elaborate-code/laravel-resource-routes
Usage example
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);
Testing
vendor/bin/pest
License
The MIT License (MIT). Please see License File for more information.