|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Credit;
-
- use App\Entity\User\UserMerchant;
- use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
- use Lc\CaracoleBundle\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();
- }
- }
|