|
|
@@ -66,8 +66,12 @@ class ProductRepository extends AbstractRepository |
|
|
|
return $this->createDefaultQuery()->count(); |
|
|
|
} |
|
|
|
|
|
|
|
public function queryProductsByDistribution(Distribution $distribution, bool $filterStatus = true) |
|
|
|
public function queryProductsByDistribution(Distribution $distribution, bool $filterStatus = true, string $orderBy = null) |
|
|
|
{ |
|
|
|
if(!$orderBy) { |
|
|
|
$orderBy = 'product_distribution.active DESC, product.order ASC'; |
|
|
|
} |
|
|
|
|
|
|
|
return $this->createDefaultQuery($filterStatus) |
|
|
|
->joinWith([ |
|
|
|
'productDistribution' => function ($query) use ($distribution) { |
|
|
@@ -76,15 +80,15 @@ class ProductRepository extends AbstractRepository |
|
|
|
); |
|
|
|
} |
|
|
|
]) |
|
|
|
->orderBy('product_distribution.active DESC, product.order ASC'); |
|
|
|
->orderBy($orderBy); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Retourne les produits d'une production donnée. |
|
|
|
*/ |
|
|
|
public function findProductsByDistribution(Distribution $distribution, bool $filterStatus = true) |
|
|
|
public function findProductsByDistribution(Distribution $distribution, bool $filterStatus = true, string $orderBy = null) |
|
|
|
{ |
|
|
|
$productArray = $this->queryProductsByDistribution($distribution, $filterStatus)->find(); |
|
|
|
$productArray = $this->queryProductsByDistribution($distribution, $filterStatus, $orderBy)->find(); |
|
|
|
return $this->buildProductsArrayById($productArray); |
|
|
|
} |
|
|
|
|