app/Http/Controllers/ProductController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Product  $product
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Product $product)
    {
        try {
            $new_product = Product::where('id', $request->id)->firstOrFail();
            $new_product->name = $request->name;
            $new_product->category = $request->category;
            $new_product->description = $request->description;
            $new_product->quantity = $request->quantity;
            $new_product->price = $request->price;
            $new_product->save();
            return redirect('product/edit/' . $new_product->id)
                ->with('status_box', 'success')
                ->with('status', trans('product.a'))
                ;
        } catch (\Exception $e) {
            return redirect('product/edit/' . $request->id)
                ->with('status_box', 'danger')
                ->with('status', 'product.b')
                ;
        }
    }
public function update ( Request $ request , Product $ product ) { try { $ new_product = Product :: where ( 'id' , $ request -> id ) -> firstOrFail ( ) ; $ new_product -> name = $ request -> name ; $ new_product -> category = $ request -> category ; $ new_product -> description = $ request -> description ; $ new_product -> quantity = $ request -> quantity ; $ new_product -> price = $ request -> price ; $ new_product -> save ( ) ; return redirect ( 'product/edit/' . $ new_product -> id ) -> with ( 'status_box' , 'success' ) -> with ( 'status' , trans ( 'product.a' ) ) ; } catch ( \ Exception $ e ) { return redirect ( 'product/edit/' . $ request -> id ) -> with ( 'status_box' , 'danger' ) -> with ( 'status' , 'product.b' ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .