Get inputs for relations.

@param array $inputs

@return array
353738
protected function getRelationInputs($inputs = [])
    {
        $relations = [];

        foreach ($inputs as $column => $value) {
            if (method_exists($this->model, $column)) {
                $relation = call_user_func([$this->model, $column]);

                if ($relation instanceof Relation) {
                    $relations[$column] = $value;
                }
            }
        }

        return $relations;
    }
18191
private function getMainFields(array $fields): array
    {
        $main = [];
        foreach ($fields as $field) {
            if ($field instanceof ChildrenAssociationField) {
                continue;
            }

            if ($field->is(Deferred::class)) {
                continue;
            }

            if (!$field->is(PrimaryKey::class)) {
                $main[] = $field;
                continue;
            }

            if ($field instanceof FkField) {
                $main[] = $field;
            }
        }

        return $main;
    }
312877
public function inputs(array $values = null): array
    {
        if ($values === null) {
            if ($this->all) {
                return $this->input;
            }

            $values = [];
            if ($this->serverRequest->getMethod() !== 'GET') {
                $values = (array) $this->serverRequest->getParsedBody();
            }

            $values += $this->serverRequest->getQueryParams();
            $this->all = true;
        }

        $this->cache = [];

        return $this->input = $values;
    }
450420
private static function getParamValues($params, $inputs) {
        foreach ($params as $key => $param) {
            if (preg_match("#^:([\[\]a-zA-Z0-9_]+)$#", $param, $param_type)) {
                $params[$key] = @$inputs[(string) $param_type[1]];
            }
        }
        return $params;
    }
1364738
public function eagerLoadRelations(array $results): array
    {
        foreach ($this->eagerLoads as $name => $constraints) {
            // First, we'll check if the entity map has a relation and just pass if it
            // is not the case

            if (!in_array($name, $this->entityMap->getRelationships())) {
                continue;
            }

            // For nested eager loads we'll skip loading them here and they will be set as an
            // eager load on the query to retrieve the relation so that they will be eager
            // loaded on that query, because that is where they get hydrated as models.
            if (strpos($name, '.') === false) {
                $results = $this->loadRelation($results, $name, $constraints);
            }
        }

        return $results;
    }
1214419
public function getAll($relations = true)
    {
        $results = array_merge($this->data, [
            'active' => $this->getActiveFieldName(),
            'created' => $this->getCreatedFieldName(),
            'filterable' => $this->getFilterableFieldNames(),
            'fields' => $this->getFields(),
            'files' => $this->getFileFieldNames(),
            'json' => $this->getJsonFieldNames(),
            'ipaddress' => $this->getIPAddressFieldName(),
            'listable' => $this->getListableFieldNames(),
            'detailable' => $this->getDetailableFieldNames(),
            'primary' => $this->getPrimaryFieldName(),
            'required' => $this->getRequiredFieldNames(),
            'searchable' => $this->getSearchableFieldNames(),
            'slugable' => $this->getSlugableFieldNames(),
            'sortable' => $this->getSortableFieldNames(),
            'uuids' => $this->getUuidFieldNames(),
            'unique' => $this->getUniqueFieldNames(),
            'updated' => $this->getUpdatedFieldName()
        ]);

        if ($relations) {
            $results['relations'] = $this->getRelations();
        }

        return $results;
    }
105772
public function getExtraRelations($models) {
        if (!$this->relationsParser){
            return [];
        }
        $relationsLeft = $this->relationsParser->getRelationsToBeSelectedSeparately();
        foreach ($relationsLeft as $path => $details){
            $this->relationsParser->getChildrenForModels($models, $path, $details, $this->fields);
        }

    }
1009783
function getRelations() {
		if (!isset($this->relations)) {
			$this->relations = new Table\Relations($this);
		}
		return $this->relations;
	}
262320
public function getRules($relation, $input)
    {
        $child = $relation->getRelated();

        // If nested is not an Image, don't do anything special.  This will result
        // in the default validation behavior which gets the rules off of the child.
        if (!is_a($child, Image::class)) {
            return;
        }

        // Check for image rules on the parent
        $parent = $relation->getParent();
        $rules_key = 'images.' . ($input['name'] ?: 'default');
        if (!array_key_exists($rules_key, $parent::$rules)) {
            return;
        }

        // Return the parent rules concatenated on the default rules for an Image
        // (those are essentially hardcoded here but I don't expect them to change)
        return [
            'file' => 'image|' . $parent::$rules[$rules_key],
        ];
    }
95818
public function update(array $inputs)
    {
        $inputs = $this->purifyInputs($inputs);

        return $this->model->update($inputs);
    }
1141995
public function getRelations($many = -1)
    {
        $results = [];
        if (!isset($this->data['relations'])
            || empty($this->data['relations'])
        ) {
            return $results;
        }

        $table = $this->getName();
        $primary = $this->getPrimaryFieldName();

        foreach ($this->data['relations'] as $relation) {
            if (is_numeric($many) && $many != -1 && $many != $relation['many']) {
                continue;
            }

            //case for getting a specific relation
            if (!is_numeric($many) && $relation['name'] !== $many) {
                continue;
            }

            $name = $table . '_' . $relation['name'];

            $results[$name] = [];

            try {
                $results[$name] = Schema::i($relation['name'])->getAll(false);
            } catch (Exception $e) {
                //this is not a registered schema
                //lets make a best guess
                $results[$name]['name'] = $relation['name'];
                $results[$name]['singular'] = ucfirst($relation['name']);
                $results[$name]['plural'] = $results[$name]['singular'] . 's';
                $results[$name]['primary'] =  $relation['name'] . '_id';
            }

            $results[$name]['table'] = $name;
            $results[$name]['primary1'] = $primary;
            $results[$name]['primary2'] = $results[$name]['primary'];
            $results[$name]['many'] = $relation['many'];
            $results[$name]['source'] = $this->getAll(false);

            //case for relating to itself ie. post_post
            if ($table === $relation['name']) {
                $results[$name]['primary1'] .= '_1';
                $results[$name]['primary2'] .= '_2';
            }

            //case for getting a specific relation
            if (!is_numeric($many) && $relation['name'] === $many) {
                return $results[$name];
            }
        }

        return $results;
    }
97331
public static function cloneRelations($sources, $clones, $relations = [])
    {
        if (!is_array($sources)) {
            $sources = [$sources];
            $clones = [$clones];
        }
        foreach ($sources as $k => $source) {
            foreach ($relations as $j => $name) {
                list($name, $except) = is_array($name) ? [$j, $name] : [$name, ['id']];
                (new static($source, $name))->cloneRelation($clones[$k], $except);
            }
        }
    }
686597
public function initRelation(array $models, $relation)
    {
        foreach ($models as $model)
        {
            // In the case of fetching nested relations, we will get an array
            // with the first key being the model we need, and the other being
            // the related model so we'll just take the first model out of the array.
            if (is_array($model)) $model = reset($model);

            $model->setRelation($relation, null);
        }

        return $models;
    }
811322
public function getImagesQuery($data, $inputs)
    {
        foreach ($inputs as $input) {
            $data[] = $this->setData(['image' => ['url' => $input->getImage()]], 'input');
        }

        return $data;
    }
1201098
protected function getRelations($keys, $constraint = null)
	{
		$this->mediate();

		if (isset($constraint))
		{
			call_user_func_array($constraint, array($this->related));
		}

		return $this->related->whereIn($this->associativeTable . '.' . $this->associativeLocal, array_unique($keys));
	}
753820
protected function sanitizeInputs(&$inputs)
    {
        if (!$this->name) {
            return $inputs;
        }

        $inputs = collect($inputs)->filter(function ($input, $key) {
            return Str::startsWith($key, "{$this->name}_");
        })->mapWithKeys(function ($val, $key) {
            $key = str_replace("{$this->name}_", '', $key);

            return [$key => $val];
        })->toArray();
    }
94444
protected static function extractSeoAttributes(array $inputs)
    {
        return [
            'title'       => Arr::get($inputs, 'seo_title'),
            'description' => Arr::get($inputs, 'seo_description'),
            'keywords'    => Arr::get($inputs, 'seo_keywords'),
            'metas'       => Arr::get($inputs, 'seo_metas', []),
        ];
    }