Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ReportDTO.php 837B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\DTO;
  3. use Livewire\Wireable;
  4. class ReportDTO implements Wireable
  5. {
  6. public function __construct(
  7. /**
  8. * @var AccountCategoryDTO[]
  9. */
  10. public array $categories,
  11. public ?AccountBalanceDTO $overallTotal = null,
  12. public array $fields = [],
  13. ) {}
  14. public function toLivewire(): array
  15. {
  16. return [
  17. 'categories' => $this->categories,
  18. 'overallTotal' => $this->overallTotal?->toLivewire(),
  19. 'fields' => $this->fields,
  20. ];
  21. }
  22. public static function fromLivewire($value): static
  23. {
  24. return new static(
  25. $value['categories'],
  26. isset($value['overallTotal']) ? AccountBalanceDTO::fromLivewire($value['overallTotal']) : null,
  27. $value['fields'] ?? [],
  28. );
  29. }
  30. }