app/Http/Controllers/UsersController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Users  $Users
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        if(Auth::user()->role=='Administrador'){
            if(isset($request->password)==false){
                $userData = request()->except(['_token','_method','password']);
                if ($request->hasFile('image')) {
                    $userData['image'] = $request->file('image')->store('images','public');
                }
                User::where('id','=',$id)->update($userData);
                return redirect('/users/'.$id.'/edit')->with('messageSuccess','Empleado Modificado con éxito'); 
            }else{
                $userData = request()->except(['_token','_method']);
                if($request->hasFile('image')){
                    $userData['image'] = $request->file('image')->store('images','public');
                }
                $userData['password'] = Hash::make($request->input('password'));
                User::where('id','=',$id)->update($userData);
                return redirect('/users/'.$id.'/edit')->with('messageSuccess','Empleado Modificado con éxito'); 
            }
    }
    }
public function update ( Request $ request , $ id ) { if ( Auth :: user ( ) -> role == 'Administrador' ) { if ( isset ( $ request -> password ) == false ) { $ userData = request ( ) -> except ( [ '_token' , '_method' , 'password' ] ) ; if ( $ request -> hasFile ( 'image' ) ) { $ userData [ 'image' ] = $ request -> file ( 'image' ) -> store ( 'images' , 'public' ) ; } User :: where ( 'id' , '=' , $ id ) -> update ( $ userData ) ; return redirect ( '/users/' . $ id . '/edit' ) -> with ( 'messageSuccess' , 'Empleado Modificado con éxito') ; } else { $ userData = request ( ) -> except ( [ '_token' , '_method' ] ) ; if ( $ request -> hasFile ( 'image' ) ) { $ userData [ 'image' ] = $ request -> file ( 'image' ) -> store ( 'images' , 'public' ) ; } $ userData [ 'password' ] = Hash :: make ( $ request -> input ( 'password' ) ) ; User :: where ( 'id' , '=' , $ id ) -> update ( $ userData ) ; return redirect ( '/users/' . $ id . '/edit' ) -> with ( 'messageSuccess' , 'Empleado Modificado con éxito') ; } } }
Update the specified resource in storage.
Update the specified resource in storage .