$this->data['page'] = $this->data['product_type'] = $productType->getPageData();
$products = Product::with('media') // Eager load media to avoid N+1 query problem
- ->where('product_type', $id)
+ ->whereVariant()
+ ->where('product_type', $id)
->where('online', 1)
->where('public', 1)
->orderBy('reference')
return $res;
}
- $raw_products = Product::where('product_type', $product_type)->where('online', 1)->where('public', 1)->get();
+ $raw_products = Product::whereVariant()->where('product_type', $product_type)->where('online', 1)->where('public', 1)->get();
$products = [];
$allids = [];
foreach ($raw_products as $idx => $raw_product) {
$newsItems = [];
$news = News::with('media')
+ ->whereVariant()
->where('type', 'news')
->orderBy('date', 'desc')
->get();
$newsItems = [];
$news = NewsModel::with('media')
+ ->whereVariant()
->where('type', 'news')
->whereDate('date', '<=', Carbon::now())
->orderBy('date', 'desc')
// Get all events
$events = NewsModel::with('media')
+ ->whereVariant()
->where('type', 'event')
->whereDate('date', '<=', $now)
->orderBy('event_start', 'asc')