|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Credit;
-
- use App\Entity\User\UserMerchant;
- use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
- use Lc\SovBundle\Repository\AbstractStore;
- use DateTime;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- class CreditHistoryStore extends AbstractStore
- {
- use MerchantStoreTrait;
-
- protected CreditHistoryRepositoryQuery $query;
-
- public function __construct(CreditHistoryRepositoryQuery $query)
- {
- $this->query = $query;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('createdAt');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->filterByMerchant($this->merchant);
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- //findAllByDateStartEnd
- public function getByDateStartEnd(DateTime $dateStart, DateTime $dateEnd, $query = null): array
- {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterByDateStart($dateStart)
- ->filterByDateEnd($dateEnd);
-
- return $query->find();
- }
-
- //findAllByUserMerchant
- public function getByUserMerchant(UserMerchant $userMerchant, $query = null): array
- {
- $query = $this->createDefaultQuery($query);
-
- $query
- ->filterByUserMerchant($userMerchant)
- ->orderBy('createdAt', 'DESC');
-
- return $query->find();
- }
- }
|