Store a newly created role in storage.

@param  \Illuminate\Http\Request  $request
@return \Illuminate\Http\Response
975646
public function store(Request $request)
    {
        // Validate the form data
        $result = $this->validate($request, [
            'name' => 'required',
            'slug' => 'required|alpha_dash|unique:roles',
        ]);

        // Create the Role
        $role = Sentinel::getRoleRepository()->createModel()->create([
            'name' => trim($request->get('name')),
            'slug' => trim($request->get('slug')),
        ]);

        // Cast permissions values to boolean
        $permissions = [];
        foreach ($request->get('permissions', []) as $permission => $value) {
            $permissions[$permission] = (bool)$value;
        }

        // Set the role permissions
        $role->permissions = $permissions;
        $role->save();

        // All done
        if ($request->expectsJson()) {
            return response()->json(['role' => $role], 200);
        }

        session()->flash('success', "Role '{$role->name}' has been created.");
        return redirect()->route('roles.index');
    }
533510
public function store(Request $request)
    {
        // Instantiate a new model item.
        $modelClass = $this->getModelClass();
        $item = new $modelClass;

        // Validate the request.
        $this->validate($request, $item->getValidationRules());

        // Create the new item.
        $itemData = $request->all();
        $item->fill($itemData);
        $item->save();

        $newItem = call_user_func([$this->getModelClass(), 'find'], $item->id)->toArray();
        return $this->generateResponse($this->modelTableName, $newItem);
    }
780092
public function store(CreateRole $request)
    {
    	 $this->validate($request, array(
	        'name' => 'required|unique:roles',
	        'code' => 'required|unique:roles',
	    ));
        $role = new Role;
		$role->name = $request->name;
		$role->code = $request->code;
		$role->save();
		
		return redirect(url("role"))->with('dp_announce', trans('deeppermission.alert.role.created'));
    }
760414
public function store(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Categories', 'create')) {
            return $this->noPermission();
        }

        $data = $request->all();
        $structuredData =  $this->generateTitleAndSlug($data['form']);
        $form = $structuredData['form'];
        $errors = $structuredData['errors'];

        // return errors if there are any
        if(count($errors)) {
            return $this->response("From errors", 400, null, false, false, true, $errors);
        }

        // if category is being created
        if(!isset($form['categoryID'])) {
            // Order item
            $catCount = Category::where("postTypeID", $request->postTypeID)->count();
            $order = $catCount+1;
            $categoryModel = new Category();
        }else{
            // if category is being updated
            $categoryModel = Category::find($form['categoryID']);
            if(!$categoryModel) {
                return $this->response("Category doesn't exist", 500);
            }
            $order = $categoryModel->order;
            $oldTitle = $categoryModel->setAutoTranslate(false)->title;
        }

        // parent ID
        $parentID = 0;
        if(isset($form['parent']['categoryID'])) {
            $parentID = $form['parent']['categoryID'];
        }

        // Create Category
        $categoryModel->title = $form['title'];
        $categoryModel->postTypeID = $data['postTypeID'];
        $categoryModel->parentID = ($parentID ? $parentID: null);
        $categoryModel->featuredImageID = $form['featuredImageID'];
        $categoryModel->description = $form['description'];
        $categoryModel->slug = $form['slug'];
        $categoryModel->isVisible = $form['isVisible'];
        $categoryModel->order = $order;
        $categoryModel->createdByUserID = Auth::user()->userID;
        $categoryModel->customFields = $request->customFieldValues;

        // return results
        if ($categoryModel->save()) {
            if(isset($form['categoryID'])) {
                // update label in menu link with the category title
                $this->updateMenuLinkLabel($data['id'], $form['title'], $oldTitle);
            }
            $redirect = $this->redirect($request->redirect, $categoryModel->categoryID, $data['postTypeID']);
            $response = $this->response('Category is saved', 200, $redirect['id'], $redirect['view'], $redirect['url']);
        }else{
            $response = $this->response('Category is not saved. Please try again later!', 500);
        }
        return $response;
    }
140192
public function store(CreateRoleRequest $request)
    {
        $input = $request->all();

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

        return $this->sendResponse($role, 'Role saved successfully.');
    }
850107
public function store(Request $request)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            'email' => 'required|email',
            'name' => 'max:36',
        ]);
        $invitedMember = $this->createInvitedMember($request);
        $memberInvitation = $this->createMemberInvitation($request->email, $invitedMember->id);
        $invitedMember->notify(new MemberInvited($memberInvitation));
        /** @noinspection PhpUndefinedMethodInspection */
        return fractal($memberInvitation, new MemberInvitationTransformer())
            ->includeInvitedMember()
            ->withResourceName('memberInvitation')
            ->respond();
    }
824365
public function store(Request $request)
	{
		$attributes = request()->validate(Settings::$rules, Settings::$messages);

        $setting = $this->createEntry(Settings::class, $attributes);

        log_activity('Setting Created', 'A Setting was successfully created', $setting);

        return redirect_to_resource();
	}
1340557
public function store(Request $request)
    {
        $this->validation->make($request->all(), [
            'name' => 'required|max:255',
            'scopes' => 'array|in:'.implode(',', Passport::scopeIds()),
        ])->validate();

        return $request->user()->createToken(
            $request->name, $request->scopes ?: []
        );
    }
115982
public function store(Request $request)
    {
        $attributes = request()->validate(News::$rules, News::$messages);

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

        return redirect_to_resource();
    }
20960
public function store(Request $request)
    {
        // insert key and value in settings table
        $settings = Settings::all()->keyBy('settingsKey')->toArray();

        foreach ($request->form as $key => $value){
            if(!isset($settings[$key])) {
                $settings[$key] = ["settingsKey" => $key, "value" => $value];
            }
            $settings[$key]['value'] = ($value ? $value : null);
        }

        if(Settings::truncate()) {
            Settings::insert($settings);
        }

        // if request is being made from general settings
        if($request->settingsType == 'general') {
            if(isset($settings['defaultLanguage']) 
                && ((int) $settings['defaultLanguage']['value'] !== Language::getDefault()->languageID)
            ) {
                    // remove the current default language ( set it to non-default ) if this new one is the default
                    Language::where('isDefault', 1)->update(['isDefault' => 0]);
                    // set the new default language
                    $defaultLanguage = $request->form['defaultLanguage'];
                    Language::find($defaultLanguage)->update(['isDefault' => 1]);
            }

        }

        return $this->response('Settings are saved', 200);
    }
826667
public function store(Request $request)
    {
        $this->authorize('create', User::class);

        $this->validate($request, [
            'name'     => 'required|max:255',
            'email'    => 'sometimes|required|email|unique:users',
            'password' => 'required|min:6|confirmed',
        ]);

        User::create($request->all());

        return redirect()->route('laralum::users.index')->with('success', __('laralum_users::general.user_created', ['email' => $request->email]));
    }
1262528
public function store(AdministratorRequest $request)
    {
        $administrator = [
            'username' => $request->get('username'),
            'password' => bcrypt($request->get('password')),
            'name' => $request->get('name'),
            'avatar' => $this->getAvatar($request)
        ];
        $user = Administrator::create($administrator);

        if ($user) {
            $roleIds = array_filter($request->get('roles'));
            $user->roles()->sync($roleIds);
        }

        return redirect()->route('admin::users.index');
    }
1261579
public function store(Request $request)
    {
        $menu = Menu::create($request->input());

        return $this->response()->item($menu, new MenuTransformer());
    }
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');
    }
144985
public function store(Request $request)
    {
        $this->validate($request, [
            'password' => 'confirmed',
        ]);

        try {
            $user = $this->users->save($request);
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => 'user']));
        }

        return redirect()->route('soda.users.edit', $user->getKey())->with('success', trans('soda::messages.created', ['object' => 'user']));
    }
1172570
public function store(Request $request)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            "memberId" => "exists:" . config('combine-core.tablePrefix', 'combine') . "_members,id",
            "memberTagId" => "exists:" . config('combine-core.tablePrefix', 'combine') . "_member_tags,id",
        ]);
        $memberTag = MemberTag::findOrFail($request->memberTagId);
        $this->authorize('attachMember', [$memberTag, $request->memberId]);
        /** @noinspection PhpUndefinedMethodInspection */
        $memberTag->members()->attach($request->memberId);
        return fractal($memberTag, new MemberTagTransformer())
            ->withResourceName('memberMemberTag')
            ->respond();
    }
1146905
public function store(Request $request)
    {
        // Validate the form data
        $result = $this->validate($request, [
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
        ]);

        // Assemble registration credentials and attributes
        $credentials = [
            'email' => trim($request->get('email')),
            'password' => $request->get('password'),
            'first_name' => $request->get('first_name', null),
            'last_name' => $request->get('last_name', null)
        ];
        $activate = (bool)$request->get('activate', false);

        // Attempt the registration
        $result = $this->authManager->register($credentials, $activate);

        if ($result->isFailure()) {
            return $result->dispatch;
        }

        // Do we need to send an activation email?
        if (!$activate) {
            $code = $result->activation->getCode();
            $email = $result->user->email;
            Mail::to($email)->queue(new CentaurWelcomeEmail($email, $code));
        }

        // Assign User Roles
        foreach ($request->get('roles', []) as $slug => $id) {
            $role = Sentinel::findRoleBySlug($slug);
            if ($role) {
                $role->users()->attach($result->user);
            }
        }

        $result->setMessage("User {$request->get('email')} has been created.");
        return $result->dispatch(route('users.index'));
    }