andWhere('.orderShop = :orderShop') ->setParameter('orderShop', $orderShop); } public function filterByProduct(ProductInterface $product): self { return $this ->andWhere('.product = :product') ->setParameter('product', $product); } public function filterByUser(UserInterface $user): self { $this->joinOrderShop(); return $this ->andWhere('orderShop.user = :user') ->setParameter('user', $user); } public function filterBySection(SectionInterface $section): self { $this->joinOrderShop(); return $this->andWhereSection('orderShop', $section); } public function filterByOrderStatus(array $status): self { $this->joinOrderStatus(); return $this ->andWhere('os.alias IN (:alias)') ->setParameter('alias', $status); } public function selectCount(): self { return $this ->select('count(r.id) as total'); } public function joinProduct(): self { if (!$this->isJoinProduct) { $this->isJoinProduct = true; return $this ->leftJoin('.product', 'product'); } return $this; } public function joinProductFamily(): self { $this->joinProduct(); if (!$this->isJoinProductFamily) { $this->isJoinProductFamily = true; return $this ->leftJoin('product.productFamily', 'productFamily'); } return $this; } public function joinOrderShop(): self { if (!$this->isJoinOrderShop) { $this->isJoinOrderShop = true; return $this ->leftJoin('.orderShop', 'orderShop'); } return $this; } public function joinOrderStatus(): self { $this->joinOrderShop(); if (!$this->isJoinOrderStatus) { $this->isJoinOrderStatus = true; return $this ->leftJoin('orderShop.orderStatus', 'os'); } return $this; } }