|
- <?php
-
- namespace common\logic\PointSale\UserPointSale\Repository;
-
- use common\logic\AbstractRepository;
- use common\logic\PointSale\PointSale\Model\PointSale;
- use common\logic\PointSale\UserPointSale\Model\UserPointSale;
- use common\logic\User\User\Model\User;
-
- class UserPointSaleRepository extends AbstractRepository
- {
- protected UserPointSaleRepositoryQuery $query;
-
- public function loadDependencies(): void
- {
- $this->loadQuery(UserPointSaleRepositoryQuery::class);
- }
-
- public function getDefaultOptionsSearch(): array
- {
- return [
- self::WITH => [],
- self::JOIN_WITH => [],
- self::ORDER_BY => '',
- self::ATTRIBUTE_ID_PRODUCER => 'point_sale.id_producer'
- ] ;
- }
-
- public function findUserPointSalesByUser(User $user): array
- {
- return $this->createDefaultQuery()
- ->joinPointSale()
- ->filterByUser($user)
- ->find();
- }
-
- public function findOneUserPointSale(User $user = null, PointSale $pointSale = null)
- {
- if(!$user || !$pointSale) {
- return null;
- }
-
- return $this->createDefaultQuery()
- ->joinPointSale()
- ->filterByUser($user)
- ->filterByPointSale($pointSale)
- ->findOne();
- }
- }
|