|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
-
- namespace Lc\CaracoleBundle\Repository\PointSale;
-
- use Knp\Component\Pager\PaginatorInterface;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Repository\AbstractRepositoryQuery;
-
- class PointSaleRepositoryQuery extends AbstractRepositoryQuery
- {
- protected $isJoinUserPointSales = false;
-
- public function __construct(PointSaleRepository $repository, PaginatorInterface $paginator)
- {
- parent::__construct($repository, 'r', $paginator);
- }
-
- public function filterByUser(UserInterface $user): self
- {
- $this->joinUserPointSales();
-
- return $this
- ->andWhere('userPointSales.user = :user')
- ->setParameter('user', $user);
- }
-
- public function filterByMerchant(MerchantInterface $merchant)
- {
- return $this
- ->andWhere(':merchant MEMBER OF .merchants')
- ->setParameter(':merchant', $merchant);
- }
-
- public function filterIsNotPublic(): self
- {
- return $this->andWhere('.isPublic = 0');
- }
-
- public function filterIsPublic(): self
- {
- return $this->andWhere('.isPublic = 1');
- }
-
- public function filterByIsPublic(int $isPublic): self
- {
- return $this->andWhere('.isPublic = ' . $isPublic);
- }
-
- public function filterLikeCode(string $code): self
- {
- return $this
- ->andWhere('.code LIKE :code')
- ->setParameter('code', $code);
- }
-
- public function joinUserPointSales(): self
- {
- if (!$this->isJoinUserPointSales) {
- $this->isJoinUserPointSales = true;
-
- return $this
- ->innerJoin('.userPointSales', 'userPointSales');
- }
- return $this;
- }
- }
|