AuthDTO.php 420 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\DTO;
  3. use App\Http\Requests\AuthRequest;
  4. readonly class AuthDTO
  5. {
  6. public function __construct(
  7. public string $email,
  8. public string $password,
  9. ) {
  10. }
  11. public static function fromRequest(AuthRequest $request): self
  12. {
  13. return new self(...$request->validated());
  14. }
  15. public function toArray(): array
  16. {
  17. return get_object_vars($this);
  18. }
  19. }