app/Http/Controllers/UsersController.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(UpdateUsersRequest $request, User $user)
    {
        $fields = $request->validated();
        $user->update($fields);
        $user->genero = $request->genero;
        $user->pais = $request->pais;
        $user->data_nasc = $request->data_nasc;
        if ($request->hasFile('img')) {
            $photo_path = $request->file('img')->store('public\users');
            $user->img = $request->file('img')->hashName();
        }
        $user->save();
        return redirect()->route('perfil')->with('success', 'Perfil editado com sucesso', compact('user'));
    }
public function update ( UpdateUsersRequest $ request , User $ user ) { $ fields = $ request -> validated ( ) ; $ user -> update ( $ fields ) ; $ user -> genero = $ request -> genero ; $ user -> pais = $ request -> pais ; $ user -> data_nasc = $ request -> data_nasc ; if ( $ request -> hasFile ( 'img' ) ) { $ photo_path = $ request -> file ( 'img' ) -> store ( 'public\users' ) ; $ user -> img = $ request -> file ( 'img' ) -> hashName ( ) ; } $ user -> save ( ) ; return redirect ( ) -> route ( 'perfil' ) -> with ( 'success' , 'Perfil editado com sucesso' , compact ( 'user' ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .