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.

41 lines
1.1KB

  1. <?php
  2. namespace common\logic\User\UserProducer;
  3. use common\logic\AbstractService;
  4. use common\logic\Producer\Producer\Producer;
  5. use common\logic\RepositoryInterface;
  6. use common\logic\User\User\User;
  7. class UserProducerRepository extends AbstractService implements RepositoryInterface
  8. {
  9. public function getDefaultOptionsSearch(): array
  10. {
  11. return [
  12. 'with' => [],
  13. 'join_with' => [],
  14. 'orderby' => '',
  15. 'attribute_id_producer' => 'user_producer.id_producer'
  16. ];
  17. }
  18. public function findOneUserProducer(User $user, Producer $producer)
  19. {
  20. return UserProducer::searchOne([
  21. 'id_user' => $user->id,
  22. 'id_producer' => $producer->id
  23. ]);
  24. }
  25. public function findUserProducersByUser(User $user, bool $active = true, bool $bookmark = true)
  26. {
  27. return UserProducer::find()
  28. ->with(['producer'])
  29. ->where([
  30. 'id_user' => $user->id,
  31. 'active' => $active,
  32. 'bookmark' => $bookmark
  33. ])
  34. ->all();
  35. }
  36. }