Package Data | |
---|---|
Maintainer Username: | Stealthpro |
Maintainer Contact: | av85.dev@gmail.com (Stealthpro) |
Package Create Date: | 2020-05-22 |
Package Last Update: | 2020-05-22 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-16 15:03:19 |
Package Statistics | |
---|---|
Total Downloads: | 46 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Form requests for Lumen Micro Framework, ported from Laravel Framework.
Support Lumen versions: 5.6+, 6.0+, 7.0+
composer require stealthpro/lumen-form-request
$app->register(Stealthpro\LumenFormRequest\Providers\FormRequestServiceProvider::class);
Refer to the official laravel documentation about form request usage
https://laravel.com/docs/master/validation#form-request-validation
<?php
namespace App\Http\Requests;
use Stealthpro\LumenFormRequest\Http\FormRequest;
class PostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'title' => [
'required',
'string',
'max:255',
'unique:posts,title',
],
'description' => 'required|string',
];
}
}
<?php
namespace App\Http\Controllers;
use App\Http\Requests\PostRequest;
use App\Http\Controllers\Controller;
class UsersController extends Controller
{
/**
* Store a new user.
*
* @param PostRequest $request
* @return Response
*/
public function store(PostRequest $request)
{
// store user
}
}