app/Http/Controllers/VinhosController.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(UpdateVinhosRequest $request, Vinhos $vinho)
    {
        $fields = $request->validated();
        $vinho->update($fields);
        if ($request->hasFile('img')) {
            $photo_path = $request->file('img')->store('public/vinhos');
            $vinho->img = $request->file('img')->hashName();
        }
        $vinho->save();
        return redirect()->route('vinhos.index')->with('success', 'Vinho editado com sucesso', compact('vinho'));
    }
public function update ( UpdateVinhosRequest $ request , Vinhos $ vinho ) { $ fields = $ request -> validated ( ) ; $ vinho -> update ( $ fields ) ; if ( $ request -> hasFile ( 'img' ) ) { $ photo_path = $ request -> file ( 'img' ) -> store ( 'public/vinhos' ) ; $ vinho -> img = $ request -> file ( 'img' ) -> hashName ( ) ; } $ vinho -> save ( ) ; return redirect ( ) -> route ( 'vinhos.index' ) -> with ( 'success' , 'Vinho editado com sucesso' , compact ( 'vinho' ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .