12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Dto;
- use App\Entity\User;
- use Symfony\Component\Validator\Constraints as Assert;
- class FiltersDTO
- {
- public function __construct(
- #[Assert\NotBlank()]
- #[Assert\GreaterThanOrEqual(10)]
- #[Assert\LessThanOrEqual(100)]
- public int $limit = 25,
- public ?User $userName = null,
-
- public null|int|string $note = 0,
-
- #[Assert\NotBlank()]
- public string $sortBy = 'dateSubmited',
- #[Assert\Choice(['ASC', 'DESC'])]
- public string $sortOrder = 'DESC',
- public ?User $userWantToView = null,
- public int $page = 1
- )
- {
- $this->note = $this->note === '' ? null : (int)$this->note;
- }
- public function toArray(): array
- {
- return [
- 'limit' => $this->limit,
- 'username' => $this->userName,
- 'sortBy' => $this->sortBy,
- 'sortOrder' => $this->sortOrder,
- 'note' => (int)$this->note,
- 'userWantToView' => $this->userWantToView,
- 'page' => $this->page
- ];
- }
- }
|