|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Reduction;
-
- use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
- use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
- use Lc\CaracoleBundle\Repository\SectionStoreTrait;
- use Lc\CaracoleBundle\Solver\Price\PriceSolver;
- use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Repository\AbstractStore;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
- use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
-
- class ReductionCartStore extends AbstractStore
- {
- use SectionStoreTrait;
-
- protected ReductionCartRepositoryQuery $query;
- protected ReductionCartSolver $reductionCartSolver;
- protected PriceSolver $priceSolver;
-
- public function __construct(
- ReductionCartRepositoryQuery $query,
- ReductionCartSolver $reductionCartSolver,
- PriceSolver $priceSolver
- ) {
- $this->query = $query;
- $this->reductionCartSolver = $reductionCartSolver;
- $this->priceSolver = $priceSolver;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('id');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- if($this->section) {
- $query->filterBySection($this->section);
- }
- $query->filterIsOnlineAndOffline();
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- // getReductionCartByCode
- public function getByCode(string $code, $query = null)
- {
- $query = $this->createDefaultQuery($query);
- $query->filterByCode($code);
- $reductionCarts = $query->find();
-
- $findReductionCart = null;
- foreach ($reductionCarts as $reductionCart) {
- if ($reductionCart && in_array($code, $reductionCart->getCodes())) {
- $findReductionCart = $reductionCart;
- }
- }
- return $findReductionCart;
- }
- }
|