merge(['password' => bcrypt($request->password)]); $user = User::create($request->all()); $user->roles()->attach($request->roles); Activation::complete($user, Activation::create($user)->code); return redirect()->route('admin.users.index') ->withSuccess(trans('admin::messages.resource_saved', ['resource' => trans('user::users.user')])); } /** * Update the specified resource in storage. * * @param int $id * @param \Modules\User\Http\Requests\SaveUserRequest $request * @return \Illuminate\Http\Response */ public function update($id, SaveUserRequest $request) { $user = User::findOrFail($id); if (is_null($request->password)) { unset($request['password']); } else { $request->merge(['password' => bcrypt($request->password)]); } $user->update($request->all()); $user->roles()->sync($request->roles); if (! Activation::completed($user) && $request->activated === '1') { Activation::complete($user, Activation::create($user)->code); } if (Activation::completed($user) && $request->activated === '0') { Activation::remove($user); } return redirect()->route('admin.users.index') ->withSuccess(trans('admin::messages.resource_saved', ['resource' => trans('user::users.user')])); } }