guglielmoseminara / l5-action-based-form-request
Action Based FormRequest for Laravel 5
v2.3.0
2021-07-06 08:57 UTC
Requires
- php: >= 7.2.5
- laravel/framework: ^8.40
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^8.4
- squizlabs/php_codesniffer: 3.*
README
Action Based FormRequest for Laravel 5
Install
Via Composer
$ composer require rafflesargentina/l5-action-based-form-request
Usage
Create a class that extends ActionBasedFormRequest. Then define methods that match the name of each action with request data you want to validate, returning an array with rules.
Example:
<?php namespace App\Http\Requests; use RafflesArgentina\ActionBasedFormRequest\ActionBasedFormRequest; class ArticleRequest extends ActionBasedFormRequest { public static function index() { return [ 'show' => 'numeric|min:1|max:400', 'order' => 'in:asc,desc', ]; } public static function store() { return [ 'title' => 'required|max:100', ]; } public static function update() { return static::store(); } }
And that's it :)
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email mario@raffles.com.ar instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.