dragon-code/extended-routes

This helper extends the standard set of resource routing methods to work with SoftDeletes and other extends

4.0.1 2024-03-15 00:21 UTC

README

Extended Routes

Stable Version Unstable Version Total Downloads Github Workflow Status License

This helper extends the standard set of resource routing methods to work with SoftDeletes and other extends.

Installation

Compatibility

To get the latest version of Extended Routes, simply require the project using Composer:

$ composer require dragon-code/extended-routes

Instead, you may of course manually update your require block and run composer update if you so choose:

{
    "require": {
        "dragon-code/extended-routes": "^4.0"
    }
}

Upgrade from andrey-helldar/extended-routes

  1. In your composer.json file, replace "andrey-helldar/extended-routes": "^2.0" with "dragon-code/extended-routes": "^3.0".
  2. Replace the Helldar\ExtendedRoutes namespace prefix with DragonCode\ExtendedRoutes in your app;
  3. Run the command composer update.
  4. Profit!

Using

With trait

use DragonCode\ExtendedRoutes\Routing\ModelBindingResolver;
use DragonCode\ExtendedRoutes\Traits\ExtendedSoftDeletes;

class Page extends Model
{
    use ExtendedSoftDeletes;
}

Extends of the abstract model

use DragonCode\ExtendedRoutes\Models\ExtendedSoftDeletes;
//use Illuminate\Database\Eloquent\SoftDeletes;

class Foo extends ExtendedSoftDeletes
{
    //use SoftDeletes; << need to remove conflicting trait.
}

Routes

app('router')->apiRestorableResource('foos', 'FoosController');

// or

Route::apiRestorableResource('foos', 'FoosController');

Referencing is also available:

use App\Http\Controllers\FoosController;

app('router')->apiRestorableResource('foos', FoosController::class);

// or

Route::apiRestorableResource('foos', FoosController::class);

License

This package is licensed under the MIT License.

This package was written with the participation of Maksim (Ellrion) Platonov under MIT License.