Package Data | |
---|---|
Maintainer Username: | soufiene-slimi |
Maintainer Contact: | s2s@mail.com (Soufiene Slimi) |
Package Create Date: | 2020-04-13 |
Package Last Update: | 2021-10-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:21:48 |
Package Statistics | |
---|---|
Total Downloads: | 93 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Missing form requests functionality for lumen, ported from laravel framework.
composer require soufiene-slimi/lumen-form-requests
$app->register(Slimi\Form\Providers\FormRequestServiceProvider::class);
Refer to the official laravel documentation about form request usage
https://laravel.com/docs/5.7/validation#form-request-validation
<?php
namespace App\Http\Requests;
use Slimi\Microservice\Foundation\Http\Requests\Request;
class CreateUserRequest extends Request
{
/**
* 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
{
$rules = [
'email' => [
'required',
'email',
'unique:users,email',
],
'password' => [
'required',
],
];
}
}
<?php
namespace App\Http\Controllers;
use App\Http\Requests\CreateUserRequest;
use App\Http\Controllers\Controller;
class UsersController extends Controller
{
/**
* Store a new user.
*
* @param CreateUserRequest $request
* @return Response
*/
public function store(CreateUserRequest $request)
{
// store user
}
}