Store user in Database.

@param  Request $request
@return array
519316
public function store(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('user', (isset($request->user['id'])) ? 'update' : 'create')) {
            return $this->noPermission();
        }
        // custom messages for validation
        $messages = array(
          'email.required'=>'You cant leave Email field empty',
          'firstName.required'=>'You cant leave name field empty',
        );

        $validatorFields = [
            'firstName' => 'required',
            'lastName' => 'required',
            'email' => 'required|unique:users',
            'groups' => 'required',
        ];

        if(isset($request->user['id'])) {
            // update user
            $user = App\Models\User::findOrFail($request->user['id']);
            $user->isActive = $request->user['isActive'];
            $currentID = $request->user['id'];
            if($user->email == $request->user['email']) {
                unset($validatorFields['email']);
            }
        }else{
            // Create user
            $user = new User();
            $user->createdByUserID = Auth::user()->userID;
            $user->password = Hash::make($request->user['password']);
            $user->isActive = 1;
            $currentID = 0;

            $validatorFields['password'] = 'required|same:confpassword';
        }

        // validation
        $validator = Validator::make($request->user, $validatorFields, $messages);

        // if validation fails return json response
        if($validator->fails()) {
            return $this->response("Please check all required fields!", 400, null, false, false, true, $validator->errors());
        }

        // if image is not set make it 0
        if (!isset($request->user['profileImageID']) || $request->user['profileImageID'] == "") {
            $profileImageID = null;
        }else{
            $profileImageID = $request->user['profileImageID'];
        }

        // Store data
        $user->email = $request->user['email'];
        $user->firstName = $request->user['firstName'];
        $user->lastName = $request->user['lastName'];
        $user->phone = $request->user['phone'];
        $user->street = $request->user['street'];
        $user->country = $request->user['country'];
        $user->slug = parent::generateSlug($request->user['firstName']." ".$request->user['lastName'], 'users', 'userID', '', $currentID, false);
        $user->about = $request->user['about'];
        $user->profileImageID = $profileImageID;
        $user->gravatar = User::getGravatarFromEmail($request->user['email']);

        if($user->save()) {
            // Add roles permissions
            $user->assignRoles($request->user['groups']);

            $redirectParams = parent::redirectParams($request->redirect, 'user', $user->userID);
            $result = $this->response('User stored successfully', 200, $user->userID, $redirectParams['view'], $redirectParams['redirectUrl']);
            $result['data'] = $user;
        }else{
            $result = $this->response('User could not be stored. Internal server error. Please try again later', 500);
        }
        return $result;
    }
125398
public function store(Create $request)
    {
        $data = $request->all();

        $user = $this->repository->create($data);

        $user->addRole($request->get('role'));

        return $this->redirect('users.index');
    }
115982
public function store(Request $request)
    {
        $attributes = request()->validate(News::$rules, News::$messages);

        $news = $this->createEntry(News::class, $attributes);

        return redirect_to_resource();
    }
296787
public function store(Request $request)
	{
		$this->validate($request, ArticleCategory::$rules, ArticleCategory::$messages);

        $this->createEntry(ArticleCategory::class, $request->only('name'));

        return redirect_to_resource();
	}
897552
public function store(Request $request) {
		$rules = [
			'sitename_ar'    => 'required',
			'sitename_en'    => 'required',
			'sitename_fr'    => 'required',
			'email'          => 'required',
			'logo'           => 'sometimes|nullable|'.it()->image(),
			'icon'           => 'sometimes|nullable|'.it()->image(),
			'system_status'  => 'required',
			'system_message' => '',
		];
		$data = $this->validate(request(), $rules, [], [
				'sitename_ar'    => trans('admin.sitename_ar'),
				'sitename_en'    => trans('admin.sitename_en'),
				'sitename_fr'    => trans('admin.sitename_fr'),
				'email'          => trans('admin.email'),
				'logo'           => trans('admin.logo'),
				'icon'           => trans('admin.icon'),
				'system_status'  => trans('admin.system_status'),
				'system_message' => trans('admin.system_message'),
			]);
		if (request()->hasFile('logo')) {
			$data['logo'] = it()->upload('logo', 'setting');
		}
		if (request()->hasFile('icon')) {
			$data['icon'] = it()->upload('icon', 'setting');
		}
		Setting::orderBy('id', 'desc')->update($data);
		session()->flash('success', trans('admin.updated'));
		return redirect(aurl('settings'));

	}
601188
public function store(Request $request)
    {
        $thread = $this->api('thread.fetch', $request->route('thread'))->parameters(['with' => ['posts']])->get();

        $this->authorize('reply', $thread);

        $post = null;
        if ($request->has('post')) {
            $post = $thread->posts->find($request->input('post'));
        }

        $post = $this->api('post.store')->parameters([
            'thread_id' => $thread->id,
            'author_id' => auth()->user()->getKey(),
            'post_id'   => is_null($post) ? 0 : $post->id,
            'content'   => $request->input('content')
        ])->post();

        $post->thread->touch();

        Forum::alert('success', 'general.reply_added');

        return redirect(Forum::route('thread.show', $post));
    }
304793
public function store(Request $request)
    {
        $this->validate(request(), [
            'name' => 'required|min:3|max:15',
            'email' => 'required|email|unique:admins',
            'password' => 'required|min:4'
        ]);

        Admin::create([
            'name' => request('name'),
            'email' => request('email'),
            'password' => bcrypt(request('password')),
            'role_id' => 1
        ]);

        session()->flash('success', 'Usuario registrado con éxito!');
        return redirect()->route('usuarios.index');
    }
492811
public function loadUsers(Request $request)
    {
        $restUsers = array();

        try {
            if ($request->query->has('roleId')) {
                $restUsers = $this->loadUsersAssignedToRole(
                    $this->requestParser->parseHref($request->query->get('roleId'), 'roleId')
                );
            } elseif ($request->query->has('remoteId')) {
                $restUsers = array(
                    $this->buildRestUserObject(
                        $this->userService->loadUser(
                            $this->contentService->loadContentInfoByRemoteId($request->query->get('remoteId'))->id,
                            Language::ALL
                        )
                    ),
                );
            } elseif ($request->query->has('login')) {
                $restUsers = array(
                    $this->buildRestUserObject(
                        $this->userService->loadUserByLogin($request->query->get('login'), Language::ALL)
                    ),
                );
            } elseif ($request->query->has('email')) {
                foreach ($this->userService->loadUsersByEmail($request->query->get('email'), Language::ALL) as $user) {
                    $restUsers[] = $this->buildRestUserObject($user);
                }
            }
        } catch (ApiExceptions\UnauthorizedException $e) {
            $restUsers = [];
        }

        if (empty($restUsers)) {
            throw new NotFoundException('No users were found with the given filter');
        }

        if ($this->getMediaType($request) === 'application/vnd.ez.api.userlist') {
            return new Values\UserList($restUsers, $request->getPathInfo());
        }

        return new Values\UserRefList($restUsers, $request->getPathInfo());
    }
347750
public function store(StoreUserValidator $request)
    {
        $user               = new User($request->all());
        $user->password     = bcrypt($request->get('password'));
        $user->is_activated = $request->get('is_activated', false);
        $user->is_blocked   = $request->get('is_blocked', false);
        $user->is_admin     = $request->get('is_admin', false);
        $user->save();
        $user->syncRoles($request->get('roles'));

        event(new UserWasCreated($user));

        flash()->success('User ' . $user->first_name . 'successfully created!');

        return redirect()->route('administrator.users.index');
    }
23376
public function store(FormRequest $request)
    {
        $data = $request->all();

        $userData = Arr::except($data, ['exit', 'permissions', 'roles', 'password_confirmation']);
        $userData['password'] = Hash::make($data['password']);
        $userData['email_verified_at'] = Carbon::now();

        $user = $this->repository->create($userData);

        if ($user) {
            $roles = $data['roles'] ?? [];
            $user->roles()->sync($roles);
            $permissions = $data['permissions'] ?? [];
            $user->syncPermissions($permissions);
        }

        return $this->redirect($request, $user);
    }
1283509
public function store(Request $request)
    {
        $this->manager->resetPath($request->folder);

        if (empty($request->name)) {
            return $this->json('Name property is required.', 422);
        }

        if (!$this->manager->blobExists()) {
            return $this->json('Folder not found.', 404);
        }

        $result = $this->manager->makeDirectory($request->name)->fullDetails();

        return $this->json($result);
    }
745332
public function store(Request $request)
    {
        $user = new \App\User();

        $user->email = $request->email;
        $user->name = $request->name;
        $user->password = Hash::make($request->password);

        $user->save();

        return redirect('scaffold-users');
    }
1266171
public function getAuthenticatedUser(Request $request)
    {
        if (!$this->checkForUserIdWithinSession($request)) {
            $this->logger->info('security.authentication.form: not authenticated');

            return null;
        }

        $id = $this->getUserIdFromSession($request);

        if (null === $user = $this->find($id)) {
            $this->logger->warning('security.authentication.form: user with id {id} is not resolvable', ['id' => $id]);
            $this->session->remove($request, self::USER_KEY);

            return null;
        }

        $this->logger->info('security.authentication.form: authenticated user with id {id}', ['id' => $id]);

        return $user;
    }
839069
public function store(Request $request)
    {
        $query = $this->getQuery();

        try {
            if ($request->input('query')) {
                $filter = new Filter($this->manager->newEntity()->getTable(), $this->queryable);
                $filter->build($query, $request->input('query'));
            }
        } catch (QuerySyntaxException $e) {
            return $this->error(['code' => 'QUERY_SYNTAX_ERROR', 'message' => 'Syntax error']);
        }

        $params = $request->only($this->fillable);

        DB::beginTransaction();

        $result = new Result();

        $query->chunk(100, function ($resources) use ($params, &$result) {
            foreach ($resources as $resource) {
                $result->addErrors($this->getManager()->update($resource, $params)->getErrors());
            }
        });

        if (!$result->ok()) {
            DB::rollBack();

            return $this->response(['errors' => $result->getSimpleErrors()], Response::HTTP_BAD_REQUEST);
        }

        DB::commit();

        return $this->response(null, Response::HTTP_OK);
    }
1209047
public function store(Request $request)
    {
        $this->validate($request, ['thread_id' => ['required'], 'author_id' => ['required'], 'content' => ['required']]);

        $thread = Thread::find($request->input('thread_id'));
        $this->authorize('reply', $thread);

        $post = $this->model()->create($request->only(['thread_id', 'post_id', 'author_id', 'content']));
        $post->load('thread');

        return $this->response($post, $this->trans('created'), 201);
    }
1061594
public function store(CreateUserRequest $request)
    {
        $input = $request->all();

        $user = $this->repository->create($input);
        $user->load($request->getWith());

        return $this->sendResponse($user, 'User saved successfully.');
    }
163049
public function authenticate(Request $request)
    {
        if ($this->session->hasValue(User::SESSION_KEY)) {
            return $this->session->value(User::SESSION_KEY);
        }

        $user = $this->authenticationProvider->authenticate($request);
        if (null === $user) {
            return null;
        }

        $this->session->putValue(User::SESSION_KEY, $user);
        return $user;
    }