elaborate-code/laravel-resource-routes

This package is abandoned and no longer maintained. The author suggests using the elaborate-code/laravel-resource-routes package instead.

A complementary Route Facade with methods to register resource routes

v1.0.0 2022-08-27 17:28 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.

Latest Version on Packagist run-tests Fix PHP code style issues PHPStan Total Downloads

banner

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.