Exemple #1
0
 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 function update(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required|min:2']);
     // Find the product that we are editing
     $product = Product::FindOrFail($id);
     $product->name = $request->name;
     $product->save();
     // Redirect the user back to the products page they just modified
     return redirect('products/' . $id);
 }