kfoobar / laravel-dto
Basic Data Transfer Object for Laravel
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:plugin
Requires
- php: ^7.4|^8.0
- illuminate/database: >=6
- illuminate/http: >=6
- nesbot/carbon: ^2.0
README
Basic Data Transfer Object for Laravel 5.5+
Installation
You can install the package via composer:
$ composer require kfoobar/laravel-dto
Basic Usage
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);
Contributing
Contributions are welcome!
License
The MIT License (MIT). Please see License File for more information.