@@ -2,8 +2,6 @@ | |||
namespace Lc\CaracoleBundle\Repository\Reminder; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Model\User\UserInterface; |
@@ -1,27 +0,0 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Repository\Reminder; | |||
use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
class TicketStore extends SovReminderStore | |||
{ | |||
protected MerchantInterface $merchant; | |||
public function setMerchant(MerchantInterface $merchant) | |||
{ | |||
$this->merchant = $merchant; | |||
} | |||
public function getFoo($query = null) | |||
{ | |||
$query = $this->query->create(); | |||
if ($this->merchant) { | |||
$query->filterByMerchant($this->merchant); | |||
} | |||
return parent::getFoo($query); | |||
} | |||
} |
@@ -8,5 +8,4 @@ use Lc\SovBundle\Repository\Ticket\TicketRepositoryQuery as SovTicketRepositoryQ | |||
class TicketRepositoryQuery extends SovTicketRepositoryQuery | |||
{ | |||
use MerchantRepositoryQueryTrait; | |||
} |
@@ -0,0 +1,51 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Repository\Ticket; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\SovBundle\Repository\Ticket\TicketStore as SovTicketStore; | |||
class TicketStore extends SovTicketStore | |||
{ | |||
use MerchantStoreTrait; | |||
public function getByUser($user, $query = null): array | |||
{ | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
} | |||
if ($this->merchant) { | |||
$query->filterByMerchant($this->merchant); | |||
} | |||
return parent::getByUser($user, $query); | |||
} | |||
public function getAllOpen(int $limit = 0, $query = null): array | |||
{ | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
} | |||
if ($this->merchant) { | |||
$query->filterByMerchant($this->merchant); | |||
} | |||
return parent::getAllOpen($limit, $query); | |||
} | |||
public function countAllOpen($query = null): array | |||
{ | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
} | |||
if ($this->merchant) { | |||
$query->filterByMerchant($this->merchant); | |||
} | |||
return parent::countAllOpen($query); | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Repository\User; | |||
use App\Entity\Merchant\Merchant; | |||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||
use Lc\SovBundle\Repository\User\UserRepositoryQuery as SovUserRepositoryQuery; | |||
class UserRepositoryQuery extends SovUserRepositoryQuery | |||
{ | |||
use MerchantRepositoryQueryTrait; | |||
protected $isJoinUserMerchants = false; | |||
public function joinUserMerchants(): self | |||
{ | |||
if (!$this->isJoinUserMerchants) { | |||
$this->isJoinUserMerchants = true; | |||
return $this | |||
->innerJoin('.userMerchants', 'um'); | |||
} | |||
return $this; | |||
} | |||
public function filterMerchantIsActive(): self | |||
{ | |||
$this->joinUserMerchants(); | |||
return $this | |||
->andWhere('um.active = 1'); | |||
} | |||
public function filterByUserMerchant(Merchant $merchant): self | |||
{ | |||
$this->joinUserMerchants(); | |||
return $this | |||
->andWhere('um.merchant = :merchant') | |||
->setParameter('merchant', $merchant); | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Repository\User; | |||
use App\Entity\Newsletter\Newsletter; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\SovBundle\Repository\User\UserStore as SovUserStore; | |||
class UserStore extends SovUserStore | |||
{ | |||
use MerchantStoreTrait; | |||
public function getByNewsletter(Newsletter $newsletter, $query = null): array | |||
{ | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
} | |||
if ($this->merchant) { | |||
$query | |||
->filterByUserMerchant($this->merchant) | |||
->filterMerchantIsActive(); | |||
} | |||
return parent::getByNewsletter($newsletter, $query); | |||
} | |||
} |