| 1234567891011121314151617181920212223242526 |
- <?php
- namespace App\DTO;
- use App\Http\Requests\UserRequest;
- readonly class UserDTO
- {
- public function __construct(
- public ?string $name = null,
- public ?string $email = null,
- public ?string $password = null,
- public ?string $type = null,
- public ?string $language = null,
- ) {}
- public static function fromRequest(UserRequest $request): self
- {
- return new self(...$request->validated());
- }
- public function toArray(): array
- {
- return get_object_vars($this);
- }
- }
|