/** * Update the specified resource in storage. * * @param User $user * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function update(User $user, Request $request) { $data = $request->all(); // If no one checkbox was checked we need to set 'roleCheck' as empty array to avoid error if (!array_key_exists('roleCheck', $data)) { $data['roleCheck'] = []; } ProfileService::update($user, $data); $user->roles()->sync($data['roleCheck']); \Session::flash('message', 'Пользователь обновлен'); return redirect()->route('admin.user.index'); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); ProfileService::createProfile($data, $user->id); return $user; }