barechain / general
General Laravel abstract classes
Installs: 1 736
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.2
- ext-json: *
- laravel/framework: >=9.0
Requires (Dev)
- psy/psysh: ^0.11.2
This package is auto-updated.
Last update: 2024-12-12 14:36:01 UTC
README
Library for general Laravel abstract classes
Requirements
- PHP >= 8.2
- Laravel >= 9.0
Installation
composer require barechain/general
DTO
<?php use Barechain\General\Dto; final class User extends Dto { public function __construct( public readonly string $firstName, public readonly string $lastName, public readonly bool $isEnabled = true ) { } } # Make new dto $dto = new User(firstName: 'John', lastName: 'Doe', isEnabled: true); $dto = new User('John', 'Doe'); $dto = new User(...['firstName' => 'John', 'lastName' => 'Doe', 'isEnabled' => false]); $dto = new User(...['John', 'Doe', false]); # Get all items in the Dto $dto->all(); # Convert to array $dto->toArray(); # Create collection $dto->collect(); # Make new Dto with named arguments $newDto = $dto->with(isEnabled: false, lastName: 'Smith');