|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Order;
-
- use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
- use Lc\CaracoleBundle\Model\Product\ProductInterface;
- use Lc\CaracoleBundle\Repository\SectionStoreTrait;
- use Lc\SovBundle\Repository\AbstractStore;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- class OrderProductStore extends AbstractStore
- {
- use SectionStoreTrait;
-
- protected OrderProductRepositoryQuery $query;
-
- public function __construct(OrderProductRepositoryQuery $query)
- {
- $this->query = $query;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('id');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- if($this->section) {
- $query->filterBySection($this->section);
- }
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- //findOrderProductsInCartsByProduct
- public function getInCartsByProduct(ProductInterface $product, $query = null): array
- {
- $query = $this->createDefaultQuery($query);
- $query->filterByProduct($product);
- $query->filterByOrderStatus(OrderStatusModel::$statusAliasAsValid);
- return $query->find();
- }
- }
|