app/Http/Controllers/UserController.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',
            'email' => 'required',
            'password' => 'required',
            'roles' => 'required|array'
        ]);
        $user = User::find($id);
        $user->name = $request->name;
        $user->email= $request->email;
        $user->password= bcrypt($request->password);
        $user->save();
        $user->roles()->sync($request->roles);
        return redirect(route('user.index'));
    }
public function update ( Request $ request , $ id ) { $ request -> validate ( [ 'name' => 'required' , 'email' => 'required' , 'password' => 'required' , 'roles' => 'required|array' ] ) ; $ user = User :: find ( $ id ) ; $ user -> name = $ request -> name ; $ user -> email = $ request -> email ; $ user -> password = bcrypt ( $ request -> password ) ; $ user -> save ( ) ; $ user -> roles ( ) -> sync ( $ request -> roles ) ; return redirect ( route ( 'user.index' ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//$user->update($request->all);