mvaliolahi/request-hydrator

Laravel 请求填充器软件包。

v1.0.4 2023-03-01 14:28 UTC

README

简介

此包向请求对象添加 castToHydrateTo 方法,以便方便地填充数据传输对象。

安装

composer require mvaliolahi/request-hydrator

如何使用

$postDTOOne = request()->castTo(PostDTO::class);

$postDTOTwo = request()->hydrateTo(PostDTO::class);

覆盖属性

$postDTO = request()->castTo(PostDTO::class, [
    'title' => ucfirst(request()->title)
]);