dees040 / persisting-requests
Laravel package for create persisting request.
Requires
- php: >=5.4.0
- illuminate/container: 5.0.x|5.1.x|5.2.x|5.3.x|5.4.x|5.5.x
This package is auto-updated.
Last update: 2024-10-25 21:55:48 UTC
README
This package will let you create persisting requests in a breeze. It will call a persisting method on your request via the Laravel Container, meaning you can use dependency injection. The package is inspired by this Laracasts video. The package can help cleaning up your controller.
Installation
Install the latest version with composer.
composer require dees040/persisting-request
After installing the packages and the service provider to the providers
array in app/config.php
.
dees040\PersistingRequests\ServiceProvider::class,
Usage
You can now run the make:persist
command.
php artisan make:persist FooBarRequest
In your controller you can now add the fresh created request to the method. Laravel will automatically inject in via dependency injection.
<?php namespace App\Http\Controllers; use App\Http\Requests\FooBarRequest; class ActivationController extends Controller { public function activate(FooBarRequest $request) { $request->persist(); return view('home'); } }
Now in your request you can add dependencies to the persisting
method.
<?php namespace App\Http\Requests; use dees040\PersistingRequests\PersistingRequest; class FooBarRequest extends PersistingRequest { /** * Persist the request. * * @return void */ public function persisting(ActivationManager $manager) { $manager->activate($this->user()); } }