/** * Store a newly created resource in storage. * * @return Response */ public function store() { // Validate the inputs // get the registration form $val = $this->userRepository->getAdminCreateForm(); // check if the form is valid if (!$val->isValid()) { return Redirect::back()->with('errors', $val->getErrors())->withInput(); } $user = $this->userRepository->model->where('email', '*****@*****.**')->first(); // If Auth Sevice Fails to Register the User if (!($user = $this->authService->register($val->getInputData()))) { return Redirect::home()->with('errors', $this->userRepository->errors()); } // Save roles. Handles updating. $roles = is_array(Input::get('roles')) ? Input::get('roles') : []; //get the user that was just addded ; $user = $this->userRepository->model->where('email', Input::get('email'))->first(); $user->saveRoles($roles); // Redirect to the new user page return Redirect::action('AdminUsersController@index')->with('success', Lang::get('admin/users/messages.create.success')); }