| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\DTO;
- use App\Http\Requests\AuthRequest;
- readonly class AuthDTO
- {
- public function __construct(
- public string $email,
- public string $password,
- ) {
- }
- public static function fromRequest(AuthRequest $request): self
- {
- return new self(
- email: $request->validated(key: 'email'),
- password: $request->validated(key: 'password'),
- );
- }
- public function toArray(): array
- {
- return [
- 'email' => $this->email,
- 'password' => $this->password,
- ];
- }
- public static function fromArray(array $data): self
- {
- return new self(
- email: $data['email'],
- password: $data['password'],
- );
- }
- }
|