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(Request $request, $id)
    {
        $request->validate([
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255'],
            'password' => ['required', 'string', 'min:8'],
            'role' => ['required', 'not_in:0']
        ]);
        $user = User::find($id);
        $user->name = $request->name;
        $user->email = $request->email;
        $user->password = Hash::make($request->password);
        $user->assignRole($request->role);
        $user->save();
        return redirect()->route('users.index')->with('info', 'Data user berhasil diupdate');
    }
public function update ( Request $ request , $ id ) { $ request -> validate ( [ 'name' => [ 'required' , 'string' , 'max:255' ] , 'email' => [ 'required' , 'string' , 'email' , 'max:255' ] , 'password' => [ 'required' , 'string' , 'min:8' ] , 'role' => [ 'required' , 'not_in:0' ] ] ) ; $ user = User :: find ( $ id ) ; $ user -> name = $ request -> name ; $ user -> email = $ request -> email ; $ user -> password = Hash :: make ( $ request -> password ) ; $ user -> assignRole ( $ request -> role ) ; $ user -> save ( ) ; return redirect ( ) -> route ( 'users.index' ) -> with ( 'info' , 'Data user berhasil diupdate' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .