|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Reduction;
-
- use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
- use Lc\CaracoleBundle\Repository\SectionStoreTrait;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\CaracoleBundle\Repository\AbstractStore;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- class ReductionCreditStore extends AbstractStore
- {
- use SectionStoreTrait;
- use MerchantStoreTrait;
-
- protected ReductionCreditRepositoryQuery $query;
-
- public function __construct(
- ReductionCreditRepositoryQuery $query
- ) {
- $this->query = $query;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('id');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $this->addFilterBySectionOptionnal($query);
- $this->addFilterByMerchantViaSectionOptionnal($query);
-
- $query->filterIsOnlineAndOffline();
-
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- // findReductionCreditsByUser
- public function getByTypeAndUser(string $type, UserInterface $user, $query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterByType($type)
- ->filterByUser($user);
-
- return $query->find();
- }
-
- // findReductionGiftToUseByUser
- public function getReductionGiftToUseByUser(UserInterface $user, $query = null)
- {
- $query = $this->createDefaultQuery($query);
- $query->filterByUser($user);
- return $query->find();
- }
-
- // findReductionGiftOwnedByUser
- public function getReductionGiftOwnedByUser(UserInterface $user, $query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterByOwner($user)
- ->filterInactive();
-
- return $query->find();
- }
-
- // findReductionGiftOwnedActiveByUser
- public function getReductionGiftOwnedActiveByUser(UserInterface $user, $query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterByOwner($user)
- ->filterActive();
-
- return $query->find();
- }
-
- }
|