paginate(5); return view('product.index', compact('products')); } public function create(): View { return view('product.create'); } public function store(Request $request): RedirectResponse { $request->validate([ 'name' => 'required|string', 'price' => 'required|numeric', 'article' => 'required|string', 'quantity' => 'required|integer', ]); Product::create($request->post()); return redirect()->route('products.index')->with('success','Product has been created successfully.'); } public function edit(Product $product): View { return view('product.edit',compact('product')); } public function update(Request $request, Product $product): RedirectResponse { $request->validate([ 'name' => 'required|string', 'price' => 'required|numeric', 'quantity' => 'required|integer', ]); $product->fill($request->post())->save(); return redirect()->route('products.index')->with('success','Product Has Been updated successfully'); } public function destroy(Product $product): RedirectResponse { $product->delete(); return redirect()->route('products.index')->with('success','Company has been deleted successfully'); } }