app/Http/Controllers/ProductController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $product = $this->productRepository->getById($id);
        if (is_null($product)) {
            return response()->json(['status' => 'KO'], 404);
        }
        $product->name = $request->get('name');
        $product = $this->productRepository->save($product);
        return response()->json($product);
    }
public function update ( Request $ request , $ id ) { $ product = $ this -> productRepository -> getById ( $ id ) ; if ( is_null ( $ product ) ) { return response ( ) -> json ( [ 'status' => 'KO' ] , 404 ) ; } $ product -> name = $ request -> get ( 'name' ) ; $ product = $ this -> productRepository -> save ( $ product ) ; return response ( ) -> json ( $ product ) ; }
Update the specified resource in storage.
Update the specified resource in storage .