Change related product logic
This commit is contained in:
parent
6eee2aaaca
commit
e1f65b0614
|
|
@ -60,12 +60,14 @@ class ProductRepository extends WProductRepository
|
||||||
* @return \Illuminate\Support\Collection
|
* @return \Illuminate\Support\Collection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function getProductsRelatedToCategoryNurgul($categoryId = null, $limit)
|
public function getProductsRelatedToCategoryNurgul($product = null, $limit)
|
||||||
{
|
{
|
||||||
$qb = $this->model->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id');
|
$qb = $this->model->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id');
|
||||||
|
|
||||||
if ($categoryId) {
|
$product = $this->find($product);
|
||||||
$qb->where('product_categories.category_id', $categoryId);
|
|
||||||
|
if (count($product->categories)) {
|
||||||
|
$qb->where('product_categories.category_id', $product->categories->first->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $qb->paginate($limit);
|
return $qb->paginate($limit);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue