mvaliolahi/request-hydrator

Laravel Request Hydrator Package.

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

README

Introduction

This package add castTo and HydrateTo methods to the request object for facilitate filling Data Transfer Objects.

Install

composer require mvaliolahi/request-hydrator

How to use

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

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

Overwrite properties

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