Change related product logic

This commit is contained in:
Amanmyrat 2023-09-15 22:08:05 +05:00
parent 6eee2aaaca
commit e1f65b0614
1 changed files with 5 additions and 3 deletions

View File

@ -60,12 +60,14 @@ class ProductRepository extends WProductRepository
* @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');
if ($categoryId) {
$qb->where('product_categories.category_id', $categoryId);
$product = $this->find($product);
if (count($product->categories)) {
$qb->where('product_categories.category_id', $product->categories->first->id);
}
return $qb->paginate($limit);