public function store(UserRequest $request) { $user = User::create($request->except('primary_group', 'secondary_group', 'password_confirmation')); $groups = array_filter(array_flatten([$request->input('primary_group'), $request->input('secondary_group')])); $user->groups()->sync($groups); return Redirect::action('UserController@index'); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ public function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }