orderBy('order', 'ASC')->get(); $meatTypes = MeatTypes::select('name', 'slug')->where('status', 1)->get(); $ct = ConsumptionTimes::select('name', 'slug')->where('status', 1)->get(); $ranges = Ranges::where('status', 1)->with('products:id,range_id,picture')->get(); return view('front.products.index', compact('productsSlides', 'ranges', 'meatTypes', 'ct')); } public function filter($slug) { // On récupère les mêmes données qu'au dessus pour l'affichage $productsSlides = ProductSliderPictures::where('status', 1)->orderBy('order', 'ASC')->get(); $ranges = Ranges::where('status', 1)->get(); $meatTypes = MeatTypes::select('name', 'slug')->where('status', 1)->get(); $ct = ConsumptionTimes::select('name', 'slug')->where('status', 1)->get(); $type = explode('/', Route::getCurrentRoute()->uri)[1]; $productsList = null; $title = null; $gamme = false; $typeViande = false; $momentConso = false; switch ($type) { case 'gamme': $gamme = Ranges::where([['slug', $slug], ['status', 1]])->firstOrFail(); if (!$gamme) { abort(404); } $productsList = $gamme->products; $title = $gamme->name; break; case 'type-viande': $meatType = MeatTypes::where([['slug', $slug], ['status', 1]])->firstOrFail(); if (!$meatType) { abort(404); } $productsList = $meatType->products; $title = $meatType->name; $typeViande = true; break; case 'moment-consommations': $consumptionTime = ConsumptionTimes::where([['slug', $slug], ['status', 1]])->firstOrFail(); if (!$ct) { abort(404); } $productsList = $consumptionTime->products; $title = $consumptionTime->name; $momentConso = true; break; default: abort(404); break; } return view('front.products.index', compact( 'productsList', 'productsSlides', 'ranges', 'meatTypes', 'ct', 'title', 'gamme', 'typeViande', 'momentConso' )); } public function departaimants() { $productsSlides = ProductSliderPictures::where('status', 1)->orderBy('order', 'ASC')->get(); $ranges = Ranges::where('status', 1)->get(); $meatTypes = MeatTypes::select('name', 'slug')->where('status', 1)->get(); $ct = ConsumptionTimes::select('name', 'slug')->where('status', 1)->get(); $productsList = Products::where([['status', 1], ['departaimants', 1]])->get(); $departaimants = true; $title = "Départ'Aimants"; return view('front.products.index', compact( 'productsList', 'departaimants', 'productsSlides', 'ranges', 'meatTypes', 'ct', 'title' )); } public function show(Products $product) { $recipes = $product->recipes()->get(); $ids = []; foreach ($recipes as $r) { $ids[] = $r->id; } $ids = array_unique($ids); $recipes = Recipes::whereIn('id', $ids)->where('status', true)->get(); return view('front.products.product', compact('product', 'recipes')); } public function indexMenusAjax(Request $request) { if (!$request->ajax()) { abort(400); } return response()->json(BalancedMenus::productsAjax()); } }