Exemple #1
  * Create a new user with data sent from the create form
  * @param  CreateUserRequest $request we validate the data sent from the form in this class before we continue our logic
  * @return \Illuminate\Support\Facades\Redirect redirect the user to the users index view
 public function store(CreateUserRequest $request, User $UserModel)
     // fill the model with the sent from the form
     // add the password after encrypting it
     $UserModel->password = bcrypt($request->input('password'));
     // save the user
     // we process the user permissions based on the new ones sent from the view
     // the message that will be sent back to the user
     $message = trans('users::users.create_success', ['name' => $UserModel->name]);
     // redirect back to the users index
     if (request('submit') == 'save') {
         return redirect()->back()->with('success', $message);
     return redirect()->route('users.index')->with('success', $message);
  * @param CreateUserRequest $request
  * @return $this|\Illuminate\Http\RedirectResponse
 public function store(CreateUserRequest $request, UserEntity $entity)
     try {
         $user = User::create($request->all());
         if ($request->has('roles')) {
         } else {
         $this->updateEntry($entity->getEntity()->id, $user->id, ['input' => $request->all()]);
         SweetAlert::success('Se ha creado el Usuario', 'Excelente!')->autoclose(3500);
     } catch (EntryValidationException $e) {
         return back()->withInput($request->all())->withErrors($e->getErrors());
     return redirect()->route('users.index');