|
- <?php
-
- namespace common\logic\User\UserProducer;
-
- use common\logic\AbstractService;
- use common\logic\Producer\Producer\Producer;
- use common\logic\RepositoryInterface;
- use common\logic\User\User\User;
-
- class UserProducerRepository extends AbstractService implements RepositoryInterface
- {
- public function getDefaultOptionsSearch(): array
- {
- return [
- 'with' => [],
- 'join_with' => [],
- 'orderby' => '',
- 'attribute_id_producer' => 'user_producer.id_producer'
- ];
- }
-
- public function findOneUserProducer(User $user, Producer $producer)
- {
- return UserProducer::searchOne([
- 'id_user' => $user->id,
- 'id_producer' => $producer->id
- ]);
- }
-
- public function findUserProducersByUser(User $user, bool $active = true, bool $bookmark = true)
- {
- return UserProducer::find()
- ->with(['producer'])
- ->where([
- 'id_user' => $user->id,
- 'active' => $active,
- 'bookmark' => $bookmark
- ])
- ->all();
- }
- }
|