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.

39 lines
934B

  1. <?php
  2. namespace domain\Product\Accessory;
  3. use domain\_\AbstractRepository;
  4. use domain\_\RepositoryQueryInterface;
  5. use yii\db\ActiveQuery;
  6. class AccessoryRepository extends AbstractRepository
  7. {
  8. protected AccessoryRepositoryQuery $query;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadQuery(AccessoryRepositoryQuery::class);
  12. }
  13. public function getDefaultOptionsSearch(): array
  14. {
  15. return [
  16. self::WITH => [],
  17. self::JOIN_WITH => [],
  18. self::ORDER_BY => 'accessory.name ASC',
  19. self::ATTRIBUTE_ID_PRODUCER => 'accessory.id_producer'
  20. ];
  21. }
  22. public function queryAccessories(): RepositoryQueryInterface
  23. {
  24. return $this->createDefaultQuery();
  25. }
  26. public function findOneAccessoryById(int $id): ?Accessory
  27. {
  28. return $this->createDefaultQuery()
  29. ->filterById($id)
  30. ->findOne();
  31. }
  32. }