public function details($id) { //$products = Product::all(); //dump($products); $prod = Product::FindOrFail($id); //dump($prod); //$catProduct = Categorie::where('name', $prod->categorie->name)->first(); $productSameCategorie = Categorie::where('id', $prod->categorie->id)->first()->products()->whereNotIn('id', [$id])->get(); return view('details', ["produit" => $prod, 'productsSameCat' => $productSameCategorie]); }
public static function getProducts($categorie, &$data) { if (is_numeric($categorie) && \Request::input('angular')) { echo Categorie::find($categorie)->products->toJson(); die; } if ($categorie = Categorie::where('href', '=', $categorie)->first()) { $categorie = $categorie->toArray(); if ($products = Categorie::find($categorie['id'])->products) { $data['contentPage'] = $products->toJson(); } } }