Basic Data Transfer Object for Laravel 5.5+
You can install the package via composer:
$ composer require kfoobar/laravel-dto
First, create a class that extends KFoobar\LaravelData\Objects\DataTransferObject:
class PostData extends DataTransferObject
{
public int $id;
public string $title;
public string $content;
}
You can then initiate and populate your object using the following methods:
$postData = new PostData::fromArray([...]);
$postData = new PostData::fromRequest($request);
$postData = new PostData::fromModel($post);
Contributions are welcome!
The MIT License (MIT). Please see License File for more information.