Download the PHP package fatbit/laravel-form-request-param without Composer
On this page you can find all versions of the php package fatbit/laravel-form-request-param. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download fatbit/laravel-form-request-param
More information about fatbit/laravel-form-request-param
Files in fatbit/laravel-form-request-param
Download fatbit/laravel-form-request-param
More information about fatbit/laravel-form-request-param
Files in fatbit/laravel-form-request-param
Vendor fatbit
Package laravel-form-request-param
Short Description this is laravel form request param
License MIT
Package laravel-form-request-param
Short Description this is laravel form request param
License MIT
Please rate this library. Is it a good library?
Informations about the package laravel-form-request-param
一个用于http请求参数的验证器, 目的是为了解决控制器层和逻辑层数据参数转换问题.
下载安装
composer require fatbit/laravel-form-request-param
使用
一. 创建form request param
类
执行下面命令, 执行完成后会在项目根目录下生成一个App\RequestParams\UserRequestParam
类文件
php artisan make:request-param user
二. 设置自己的请求参数
注解详细传参请查看注解类里的注释
use Fatbit\FormRequestParam\Abstracts\AbstractFormRequestParam;
use Fatbit\FormRequestParam\Annotations\FormRequestRule;
use Fatbit\FormRequestParam\Annotations\FormRequestArrayRule;
class UserRequestParam extends AbstractFormRequestParam
{
#[FormRequestRule('required|string|max:255', '姓名')]
public string $name;
#[FormRequestRule('required|integer|in:1,2', '性别')]
public int $sex;
#[FormRequestRule(['required','integer'], '年龄')]
public int $age;
#[FormRequestRule('required|string|max:255', '账号', 'username')]
public string $account;
#[FormRequestRule('required|array', '标签')]
#[FormRequestArrayRule('*', 'required|int|gt:0', '标签Id')]
public array $tags;
}
三. 引用请求参数
可以引用多个`RequestParam`接收请求的时候会验证所有的字段规则
class UserController
{
public function create(UserRequestParam $requestParam)
{
return $this->success($this->service->create($requestParam));
}
public function modify(IdRequestParam $idRequestParam, UserRequestParam $requestParam)
{
return $this->success($this->service->modify($idRequestParam->id, $requestParam));
}
}
All versions of laravel-form-request-param with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
ext-json Version *
ext-json Version *
The package fatbit/laravel-form-request-param contains the following files
Loading the files please wait ....