Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance - Dashboard Controller #7188

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function getTopSellingCategories()
*/
public function getStockThreshold()
{
return $this->productInventoryRepository->getModel()
return $this->productInventoryRepository->getModel()->with(['product', 'product.attribute_family', 'product.attribute_values', 'product.images'])
->leftJoin('products', 'product_inventories.product_id', 'products.id')
->select(DB::raw('SUM(qty) as total_qty'))
->addSelect('product_inventories.product_id')
Expand All @@ -213,7 +213,7 @@ public function getStockThreshold()
*/
public function getTopSellingProducts()
{
return $this->orderItemRepository->getModel()
return $this->orderItemRepository->getModel()->with(['product', 'product.images'])
->select(DB::raw('SUM(qty_ordered) as total_qty_ordered'))
->addSelect('id', 'product_id', 'product_type', 'name')
->where('order_items.created_at', '>=', $this->startDate)
Expand All @@ -226,7 +226,7 @@ public function getTopSellingProducts()
}

/**
* Returns cutomer with most sales.
* Returns customer with most sales.
*
* @return \Illuminate\Support\Collection
*/
Expand Down