andrey-helldar / extended-routes
This helper extends the standard set of resource routing methods to work with SoftDeletes and other extends
Fund package maintenance!
Boosty
Yoomoney
Donationalerts
Installs: 6 025
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: ^8.1
- illuminate/database: ^10.0 || ^11.0
- illuminate/routing: ^10.0 || ^11.0
- illuminate/support: ^10.0 || ^11.0
Requires (Dev)
- orchestra/testbench: ^8.0 || ^9.0
- phpunit/phpunit: ^10.0
README
This helper extends the standard set of resource routing methods to work with SoftDeletes and other extends.
Installation
Compatibility
Laravel | PHP | Extended Routes Version |
---|---|---|
7, 8, 9, 10 | 7.3, 7.4, 8.0, 8.1, 8.2 | ^3.0 |
10, 11 | 8.1, 8.2, 8.3 | ^4.0 |
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
- In your
composer.json
file, replace"andrey-helldar/extended-routes": "^2.0"
with"dragon-code/extended-routes": "^3.0"
. - Replace the
Helldar\ExtendedRoutes
namespace prefix withDragonCode\ExtendedRoutes
in your app; - Run the
command composer
update. - 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);
Method | URI | Name | Action | Middleware |
---|---|---|---|---|
GET/HEAD | api/foos | foos.index | App\Http\Controllers\FoosController@index | api |
POST | api/foos | foos.store | App\Http\Controllers\FoosController@store | api |
GET/HEAD | api/foos/trashed | foos.trashed | App\Http\Controllers\FoosController@trashed | api |
GET/HEAD | api/foos/{foo} | foos.show | App\Http\Controllers\FoosController@show | api |
PUT/PATCH | api/foos/{foo} | foos.update | App\Http\Controllers\FoosController@update | api |
DELETE | api/foos/{foo} | foos.destroy | App\Http\Controllers\FoosController@destroy | api |
POST | api/foos/{foo}/restore | foos.restore | App\Http\Controllers\FoosController@restore | api |
License
This package is licensed under the MIT License.
This package was written with the participation of Maksim (Ellrion) Platonov under MIT License.