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.

UserProducerRepositoryQuery.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace common\logic\User\UserProducer\Repository;
  3. use common\logic\AbstractRepositoryQuery;
  4. use common\logic\User\User\Model\User;
  5. use common\logic\User\UserProducer\Model\UserProducer;
  6. use common\logic\User\UserProducer\Service\UserProducerDefinition;
  7. use yii\db\ActiveQuery;
  8. class UserProducerRepositoryQuery extends AbstractRepositoryQuery
  9. {
  10. protected UserProducerDefinition $definition;
  11. public function loadDependencies(): void
  12. {
  13. $this->loadDefinition(UserProducerDefinition::class);
  14. }
  15. public function filterByUser(User $user): self
  16. {
  17. $this->andWhere(['id_user' => $user->id]);
  18. return $this;
  19. }
  20. public function filterByActive(bool $active): self
  21. {
  22. $this->andWhere(['active' => $active]);
  23. return $this;
  24. }
  25. public function filterByBookmark(bool $bookmark): self
  26. {
  27. $this->andWhere(['bookmark' => $bookmark]);
  28. return $this;
  29. }
  30. public function filterHasNegativeOrPositiveCredit(): self
  31. {
  32. $this->andWhere('user_producer.credit IS NOT NULL AND user_producer.credit != 0');
  33. return $this;
  34. }
  35. }