set the relations

@param $request
@return void
542674
protected function setRelation($request)
    {
        $this->changeRelationModel();
        $relation = [];
        if ($request->has('group-thumbnail')) {
            $this->relations['thumbnails']['datas'] = collect($request->get('group-thumbnail'))->reject(function($item)
            {
                return ! $item['thumbnail_slug'] || ! $item['thumbnail_width'] || ! $item['thumbnail_height'];
            })->map(function($item,$key)
            {
                $item['slug'] = $item['thumbnail_slug'];
                unsetReturn($item,'thumbnail_slug');
                $item['photo_width'] = $item['thumbnail_width'];
                unsetReturn($item,'thumbnail_width');
                $item['photo_height'] = $item['thumbnail_height'];
                unsetReturn($item,'thumbnail_height');
                return $item;
            });
            if ($this->relations['thumbnails']['datas']->count() > 0) $relation[] = $this->relations['thumbnails'];
        }
        if ($request->has('group-extra')) {
            $this->relations['extras']['datas'] = collect($request->get('group-extra'))->reject(function($item)
            {
                return ! $item['extra_name'] || ! $item['extra_type'];
            })->map(function($item,$key)
            {
                $item['name'] = $item['extra_name'];
                unsetReturn($item,'extra_name');
                $item['type'] = $item['extra_type'];
                unsetReturn($item,'extra_type');
                return $item;
            });
            if ($this->relations['extras']['datas']->count() > 0) $relation[] = $this->relations['extras'];
        }
        $this->setOperationRelation($relation);
    }
1313441
public function store($request) {
        $this->resolveModel();
        $model = Dir::apiModel($this->model);
        $model = new $model();

        if(!empty($request->relationalModel)) {
            $idRelationalModel = trim(strtolower($request->relationalModel), 's');
            $idRelationalModel =  $idRelationalModel.'Id';
            $model->$idRelationalModel = $request->idRelational;
        }

        foreach($model->getTuples() as $tuple) {
            if(empty($idRelationalModel))
                empty($request->$tuple) ? killer('400') : $model->$tuple = $request->$tuple;
            else if($tuple != $idRelationalModel)
                empty($request->$tuple) ? killer('400') : $model->$tuple = $request->$tuple;
        }

        $model->save();
        return $model;
    }
537666
private function setTicket($request)
	{
		$ticket = array(
				'id' => $request['ticket'],
				'create_at' => $request['create_at'],
				'expire_time' => $request['expire_time'],
				'check_at' => $request['check_at']
			);
		$this->setCookie($ticket);
		$userInfo = $this->chanslate_add_to_empty($request['user']);
		$userInfo = $this->decrypt($userInfo);
		$userInfo = $this->chanslate_json_to_array($userInfo);
		$this->setSession($ticket,$userInfo);
	}
258241
public static function initialize($request)
    {
        Menu::setPrimaryMenuID();

        //Backend
        if (isInAdmin()) {
            $menuLinkID = (is_numeric(Input::get('menu_link_id')) ? Input::get('menu_link_id') : false);
            if($menuLinkID) {
                self::setCurrent(self::findByID($menuLinkID));
            }
        }else{ // frontend
            Post::sethomepage();

            // Set active menulinks
            self::setActiveIDs();

            // Set home page MenuLink if home page is requested
            $getCurrentPath = Request::path();
            if($getCurrentPath == '/' || $getCurrentPath == App::getLocale()) {
                self::setCurrent(Post::gethomepage());
            }else if(self::getActiveIDs()) {
                //or if any other menulink is active
                self::setCurrent(self::findByID(array_first(self::getActiveIDs())));
            }

            // Front page should not have duplicate urls
            if(Request::route('postSlug') && Request::route('postSlug') == Post::gethomepage()->slug) {
                Redirect::to('/', 301)->send();
            }
        }
    }
167884
private function setRequest(Request $request = null)
    {
        $this->request = $request;
        $this->override = null;
    }
576126
public function handleRequest(Request $request): void
    {
        $this->getForm()->handleRequest($request);
        $this->handleForm($request->get('page'));
    }
259466
public function linkToMany($model, $link): void
    {
        Relations::setRelations($this->model, $model, [$link]);
    }
931052
public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);

        $payment = $request->getModel();

        $details = $payment->getDetails();

        if (array_key_exists(Constants::FIELD_PAID, $details)) {
            return;
        }

        $details[Constants::FIELD_PAID] = false;

        $payment->setDetails($details);

        return;
    }
52969
public function setRequest(Request $request)
    {
        $this->request = $request;
        $this->getContainer()->register('request', $request);
        return $this;
    }
265440
public function init($request)
    {
        $sElementTable = $request->getParameter("elementtable");
        $sShopId = $request->getParameter("shopid");
        $sParentShopId = $request->getParameter("parentshopid");
        $sElementId = $request->getParameter("elementid");
        if ($sElementId) {
            $this->assignElementToSubShop($sElementTable, $sShopId, $sElementId);
        } else {
            $this->assignAllElementsToSubShop($sElementTable, $sShopId, $sParentShopId);
        }
    }
15949
protected function addDefaultParameters(&$request)
	{
		$defaultParameters = array(
			'all'=>1,
			'dir'=>'ASC',
			'start'=>0,
			'limit'=>999999999);

		foreach ($defaultParameters as $name=> $value)
			$request->getPost()->set($name, $value);
	}
557901
public function setRequest($request)
    {
        $return = parent::setRequest($request);
        $this->setURLParams($this->getRequest()->allParams());

        return $return;
    }
942930
public function setRelated($value)
    {
        $this->loadData(true);

        if (is_null($value)) {
            $value = [];
        }

        if (!is_array($value)) {
            throw new RelationException("HasMany relation can only be set with array of entities");
        }

        //Do not add items twice
        $matched = [];
        foreach ($value as $index => $item) {
            if (is_null($item)) {
                unset($value[$index]);
                continue;
            }

            $this->assertValid($item);
            if (!empty($instance = $this->matchOne($item))) {
                $matched[] = $instance;
                unset($value[$index]);
            }
        }

        $this->deleteInstances = array_diff($this->instances, $matched);
        $this->instances = $matched + $value;
    }
1158094
public static function setRequest(RequestInterface $request)
    {
        $fd = self::getFdByCoId();

        self::$connections[$fd][self::REQUEST_KEY] = $request;
    }
1056523
public function setRelation(Row $row): void
    {
        $modelName = $row->getTable()->getModel();
        $this->relations[$modelName] = [$row];
    }
258648
public function init(HTTPRequest $request)
    {

        if (!$this->isStarted() && $this->requestContainsSessionId($request)) {
            $this->start($request);
        }

        // Funny business detected!
        if (isset($this->data['HTTP_USER_AGENT'])) {
            if ($this->data['HTTP_USER_AGENT'] !== $this->userAgent($request)) {
                $this->clearAll();
                $this->destroy();
                $this->started = false;
                $this->start($request);
            }
        }
    }
303854
public function setRequest(SimplifiedRequest $request)
    {
        if (!$this->element) {
            $this->setMatchElement($request->pathinfo);
        }

        parent::setRequest($request);
    }