app/Http/Controllers/ProductController.php
// update function to update the selected product info
update function to update the selected product info
update function to update the selected product info
public function update(Request $request,$id){
        $product = Product::find($id);
        if($product == null){
            return response()->json("Product Item Not Found");    
        }
        $product->name = $request->input('name');
        $product->price = $request->input('price');
        $product->description = $request->input('description');
        $product->save();
        return response()->json($product);
    }
public function update ( Request $ request , $ id ) { $ product = Product :: find ( $ id ) ; if ( $ product == null ) { return response ( ) -> json ( " Product Item Not Found " ) ; } $ product -> name = $ request -> input ( 'name' ) ; $ product -> price = $ request -> input ( 'price' ) ; $ product -> description = $ request -> input ( 'description' ) ; $ product -> save ( ) ; return response ( ) -> json ( $ product ) ; }
update function to update the selected product info
update function to update the selected product info
// get the prodcut from database // update the product item // save the updated product