app/Http/Controllers/ProductController1.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Product  $product
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'prod_name' => 'required',
            'prod_price' => 'required',
        ]);
        if($validator->fails()){
            return $this->sendError('Error validation', $validator->errors());       
        }
        $update =  Product::find($request->id);
        $update->prod_name = $request->prod_name;
        $update->prod_price = $request->prod_price;
        $update->update();
        return $this->sendResponse($update,'Update Product Successfully');
    }
public function update ( Request $ request ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'prod_name' => 'required' , 'prod_price' => 'required' , ] ) ; if ( $ validator -> fails ( ) ) { return $ this -> sendError ( 'Error validation' , $ validator -> errors ( ) ) ; } $ update = Product :: find ( $ request -> id ) ; $ update -> prod_name = $ request -> prod_name ; $ update -> prod_price = $ request -> prod_price ; $ update -> update ( ) ; return $ this -> sendResponse ( $ update , 'Update Product Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .