You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AccountDTO.php 834B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\DTO;
  3. use Livewire\Wireable;
  4. class AccountDTO implements Wireable
  5. {
  6. public function __construct(
  7. public string $accountName,
  8. public string $accountCode,
  9. public ?int $accountId,
  10. public AccountBalanceDTO $balance,
  11. ) {}
  12. public function toLivewire(): array
  13. {
  14. return [
  15. 'accountName' => $this->accountName,
  16. 'accountCode' => $this->accountCode,
  17. 'accountId' => $this->accountId,
  18. 'balance' => $this->balance->toLivewire(),
  19. ];
  20. }
  21. public static function fromLivewire($value): static
  22. {
  23. return new static(
  24. $value['accountName'],
  25. $value['accountCode'],
  26. $value['accountId'],
  27. AccountBalanceDTO::fromLivewire($value['balance']),
  28. );
  29. }
  30. }