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 = Product::find($id);
        $product->fill($request->except('file'));
        if($request->hasFile('file')){
            $file = $request->file('file');
            $name = time().$file->getClientOriginalName();
            $product->file = $name;
            $file->move(public_path().'/image/',$name);
        }
        $product->update();
        return redirect()->route('products.edit', $product->id)->with('info', 'Producto actualizado con éxito');
    }
public function update ( Request $ request , $ id ) { $ product = Product :: find ( $ id ) ; $ product -> fill ( $ request -> except ( 'file' ) ) ; if ( $ request -> hasFile ( 'file' ) ) { $ file = $ request -> file ( 'file' ) ; $ name = time ( ) . $ file -> getClientOriginalName ( ) ; $ product -> file = $ name ; $ file -> move ( public_path ( ) . '/image/' , $ name ) ; } $ product -> update ( ) ; return redirect ( ) -> route ( 'products.edit' , $ product -> id ) -> with ( 'info' , 'Producto actualizado con éxito') ; }
Update the specified resource in storage.
Update the specified resource in storage .