Package Data | |
---|---|
Maintainer Username: | noitran |
Maintainer Contact: | noitran.black@gmail.com (Noitran.Noitran) |
Package Create Date: | 2018-03-23 |
Package Last Update: | 2020-02-10 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:12:51 |
Package Statistics | |
---|---|
Total Downloads: | 4,705 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 5 |
Total Watchers: | 2 |
Total Forks: | 4 |
Total Open Issues: | 0 |
Missing form requests functionality for lumen, ported from laravel framework.
composer require noitran/lumen-form-requests
$app->register(Noitran\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 Noitran\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
}
}