route("product.create"); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view("product/create"); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { Log::debug($request); $request->validate([ 'name'=>'required', 'description'=>'required', ]); $product = new Product([ 'name' => $request->get("name"), 'description' => $request->get("description") ]); $product->save(); //echo $product->uuid; return redirect()->route("product.show", [ 'product' => $product])->with("message", "Product created successfully"); } /** * Display the specified resource. * * @param \App\Models\Product $product * @return \Illuminate\Http\Response */ public function show(Product $product) { return view("product/view", ["product" => $product]); } /** * Show the form for editing the specified resource. * * @param \App\Models\Product $product * @return \Illuminate\Http\Response */ public function edit(Product $product) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Product $product * @return \Illuminate\Http\Response */ public function update(Request $request, Product $product) { $product->fill($request->all()); $product->save(); return redirect()->route("product.show", [ 'product' => $product])->with("message", "Product created successfully"); } /** * Remove the specified resource from storage. * * @param \App\Models\Product $product * @return \Illuminate\Http\Response */ public function destroy(Product $product) { $product->delete(); return redirect()->route("product.index"); } }