Save details.

@param Request $request

@return ResultResponse
@Route("/savedetails", name="users_options_savedetails")
543508
public function savedetailsAction(Request $request)
    {
        $user = $this->getUser()
            ->setFirstname($request->request->get('firstname'))
            ->setLastname($request->request->get('lastname'))
            ->setEmail($request->request->get('email'));

        $this->get('phlexible_user.user_manager')->updateUser($user);

        return new ResultResponse(true, 'User details saved.');
    }
310080
public function store(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Menu', 'create')) {
            return $this->noPermission();
        }

        // delete menu links from database
        if ($request->deletedMenuLinks) {
            $ids = [];
            foreach ($request->deletedMenuLinks as $menuLinkID){
                if (!strstr($menuLinkID, 'NEW')) {
                    $ids[] = $menuLinkID;
                }
            }
            MenuLink::whereIn('menuLinkID', $ids)->delete();
        }

        // create menu if it doesn't exist
        if (!$request->selectedMenuID) {
            $slug = self::generateSlug($request->selectedMenu['title'], 'menus', 'menuID');

            $menu = new Menu();
            $menu->title = $request->selectedMenu['title'];
            $menu->slug = $slug;
            $menu->isPrimary = 0;

            if($menu->save()) {
                $menuID = $menu->menuID;
            }else{
                throw new \Exception("New MenuLinks could not be saved. Please contact your administrator!");
            }
        }else{
            // update menu if it exists
            $menuID = $request->selectedMenuID;

            $menu = Menu::findOrFail($menuID);
            $menu->title = $request->selectedMenu['title'];

            if(!$menu->save()) {
                throw new \Exception("New MenuLinks could not be saved. Please contact your administrator!");
            }
        }

        // convert menu links from multidimension to one dimension array
        $this->convertTo1Dimension($request->menuLinkList);
        // prepare array for storing
        $this->prepareArrayForStore($request->menuLinkListAfterOrder, $this->tmpMenuLinkInfo, $menuID);

        $newMenuLinksID = [];
        // create the new menu links for the selected menu
        foreach($this->newMenuLinks as $menuLinkKey=>$menuLink){

            //if parent is a new link get his id from $newMenuLinksID
            $isParentNewLink = strstr($menuLink['parent'], 'NEW');
            if($isParentNewLink) {
                $menuLink['parent'] = $newMenuLinksID[$menuLink['parent']];
            }

            //we don't need these anymore
            if(isset($menuLink['menuLinkID'])) { unset($menuLink['menuLinkID']); 
            }
            if(isset($menuLink['routeList'])) { unset($menuLink['routeList']); 
            }
            if(isset($menuLink['href'])) { unset($menuLink['href']); 
            }
            if(isset($menuLink['belongsToData'])) { unset($menuLink['belongsToData']); 
            }

            $this->newMenuLinks[$menuLinkKey] = self::objectsToJson($menuLink);
        }

        // Fire event
        Event::fire('menuLink:creating', [$this->newMenuLinks, $request]);

        // insert menulinks
        $insertMenuLinks = DB::table('menu_links')->insert($this->newMenuLinks);

        if($insertMenuLinks) {
            // Fire event
            Event::fire('menuLink:created', [$insertMenuLinks, $request]);
        }else{
            throw new \Exception("New MenuLinks could not be saved. Please contact your administrator!");
        }

        // update links
        $existingMenuLinks = $this->setParentID($newMenuLinksID);
        foreach($existingMenuLinks as $menuLink){
            $menuLink = self::objectsToJson($menuLink);
            $menuLinkID = $menuLink['menuLinkID'];
            if(isset($menuLink['menuLinkID'])) { unset($menuLink['menuLinkID']); 
            }
            if(isset($menuLink['routeList'])) { unset($menuLink['routeList']); 
            }
            if(isset($menuLink['href'])) { unset($menuLink['href']); 
            }
            if(isset($menuLink['routes'])) { unset($menuLink['routes']); 
            }

            // Fire event
            Event::fire('menuLink:updating', [$menuLink, $request]);

            MenuLink::where('menuLinkID', $menuLinkID)->update($menuLink);

            // Fire event
            Event::fire('menuLink:updated', [$menuLink, $request]);
        }

        return $this->response('Menu is successfully saved', 200, $menuID);

    }
235022
public function savepreferencesAction(Request $request)
    {
        $user = $this->getUser()
            ->setInterfaceLanguage($request->request->get('interfaceLanguage', 'en'));

        $this->get('phlexible_user.user_manager')->updateUser($user);

        return new ResultResponse(true, 'User preferences saved.');
    }
461266
public function store(Request $request)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            "name" => "required|max:75",
            "email" => "required|email|max:75|unique:users",
        ]);
        $user = new User;
        $user->name = $request->get("name");
        $user->email = $request->get("email");
        $user->save();
        return response()->json($user, 201);
    }
353049
public function saveAction(Request $request)
    {
        $treeSaver = $this->get('phlexible_elementtype.tree_saver');

        $elementtype = $treeSaver->save($request, $this->getUser());

        return new ResultResponse(
            true,
            "Element Type {$elementtype->getTitle()} saved as version {$elementtype->getRevision()}."
        );
    }
731067
public function store(Request $request)
    {
        try {
            $validation = app(ValidationService::class)->check(Menu::$rules);

            if (!$validation['errors']) {
                $menu = $this->repository->store($request->all());
                Cms::notification('Menu saved successfully.', 'success');

                if (!$menu) {
                    Cms::notification('Menu could not be saved.', 'danger');
                }
            } else {
                return $validation['redirect'];
            }
        } catch (Exception $e) {
            Cms::notification($e->getMessage() ?: 'Menu could not be saved.', 'danger');
        }

        return redirect(route($this->routeBase.'.menus.edit', [$menu->id]));
    }
1164200
public function store(Request $request)
    {
        $menu = Dashboard::model(Menu::class)::create(array_merge($request->input('params.data'), [
            'lang'   => $request->input('params.lang'),
            'type'   => $request->input('params.menu'),
            'parent' => 0,
        ]));

        return response()->json([
            'type' => 'success',
            'id'   => $menu->id,
        ]);
    }
1215980
public function store(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Media', 'create')) {
            return $this->noPermission();
        }
        return (new Media())->upload($request);
    }
13168
public function store(Request $request)
    {
        $user_setting = new User_setting();

        
        $user_setting->user_id = $request->user_id;

        
        $user_setting->setting_id = $request->setting_id;

        
        $user_setting->notes = $request->notes;

        
        
        $user_setting->save();

        return redirect('user_setting');
    }
137761
protected function saveElements(\Illuminate\Http\Request $request)
    {
        $this->getElements()->onlyActive()->each(function ($element) use ($request) {
            $element = $this->getElementContainer($element);

            if ($element instanceof FormElementInterface) {
                $element->save($request);
            }
        });
    }
1167410
public function store(Request $request)
    {
        $this->validate($request, [
            'name'      => 'required',
            'color'     => 'required',
        ]);

        $status = new Status();
        $status->create(['name' => $request->name, 'color' => $request->color]);

        Session::flash('status', trans('ticketit::lang.status-name-has-been-created', ['name' => $request->name]));

        \Cache::forget('ticketit::statuses');

        return redirect()->action('\Kordy\Ticketit\Controllers\StatusesController@index');
    }
1213824
public function store(Request $request)
    {
        $this->validate($request, ['name' => 'required']);

        $role = Role::create($request->all());
        $role->permissions()->detach();

        if ($request->has('permissions')) {
            foreach ($request->permissions as $permission_name) {
                $permission = Permission::whereName($permission_name)->first();
                $role->givePermissionTo($permission);
            }
        }

        return redirect('admin/roles')->with('flash_message', 'Role added!');
    }
857102
public function saveAction(Request $request)
    {
        $id = $request->get('id');
        $ids = $request->get('ids');

        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
        $elementtype = $elementtypeService->findElementtype($id);

        $elementtypeService->updateViability($elementtype, $ids);

        return new ResultResponse(true);
    }
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();
	}
1111954
public function store(Request $request)
    {
        $validation = $this->validation->check(File::$rules);

        if (!$validation['errors']) {
            $file = $this->repository->store($request->all());
        } else {
            return $validation['redirect'];
        }

        Cms::notification('File saved successfully.', 'success');

        return redirect(route($this->routeBase.'.files.index'));
    }
1335539
public function savethemeAction(Request $request)
    {
        $user = $this->getUser()
            ->setProperty('theme', $request->request->get('theme', 'default'));

        $this->get('phlexible_user.user_manager')->updateUser($user);

        return new ResultResponse(true, 'User theme saved.');
    }
1153994
public function store(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Tags', 'create')) {
            return $this->noPermission();
        }

        $validatorData = [
            'title' => 'required',
            'postTypeID' => 'required',
            'slug' => 'required|max:500|unique:tags',
        ];

        if(isset($request->formData['id'])) {
            // Update Tag
            $tags = Tag::findOrFail($request->formData['id']);
            $validatorData['slug'] = 'required';
        }else{
            $tags = new Tag();
            $tags->createdByUserID = Auth::user()->userID;
            $tags->postTypeID = $request->formData['postTypeID'];
        }

        // validation
        $validator = Validator::make($request->formData, $validatorData, []);
        // check validation
        if ($validator->fails()) {
            return $this->response("Please check all required fields!", 400, null, false, false, true, $validator->errors());
        }

        $tags->title         = $request->formData['title'];
        $tags->description   = $request->formData['description'];
        $tags->slug          = $request->formData['slug'];
        $tags->featuredImageID = ($request->formData['featuredImage']  !== 0 ? $request->formData['featuredImage'] : null);

        // return results
        if ($tags->save()) {
            $redirect = $this->redirect($request->formData['redirect'], $tags->tagID, $request->formData['postTypeID']);
            $result = $this->response('Tag is saved', 200, $redirect['id'], $redirect['view'], $redirect['url']);
        }else{
            $result = $this->response('Internal server error. Please try again later', 500);
        }
        return $result;
    }