Returns the cached relations for a given
parent model.

@param $model

@return array
7005
public static function all($parent)
    {
        is_eloquent_object($parent, true);
        $cache = static::getCache();
        if (isset($cache[$parent])) {
            return $cache[$parent];
        }

        return [];
    }
351080
protected function showRelatoins(Model $model)
    {
        $name = $this->manager->getClassName($model);

        $this->title("Relations of Model {$name}: ");

        $relations = $this->manager->getRelations($model);
        $tbody = [];

        foreach ($relations as $relation) {
            $relationName = $this->manager->getClassName($relation);
            $related = $relation->getRelated() ?:null;

            $tbody[] = [
                $this->paintString($relationName, 'brown'),
                $related ? $this->manager->getClassName($related) : '',
            ];
        }

        $this->table(['relation', 'model'], $tbody);
    }
250865
protected function fetchModelScopes($model)
    {
        $reflection = new \ReflectionClass($model);

        foreach ($reflection->getMethods() as $method) {
            if (preg_match('~^scope(.+)$~i', $method->name, $match)) {
                if ($this->isHiddenScope($name = $match[1])
                    || $this->isDynamicScope($method)
                    || $this->hasHiddenFlag($method->getDocComment())
                    || 'scopeTranslated' === $match[0]) {
                    continue;
                }

                $scope = with(new Scope($name))->setQuery([$model, $name]);
                if ($icon = $this->hasIconFlag($method->getDocComment())) {
                    $scope->setIcon($icon);
                }

                $this->addScope($scope);
            }
        }
    }
960573
public function getRelationSavingModels($relation)
    {
        $result = isset($this->savingModels[$relation])
            ? $this->savingModels[$relation]
            : $this->owner->$relation;
        return is_array($result) && (!$this->owner->getRelation($relation)->multiple)
            ? reset($result) : $result;
    }
84989
public function getOldRelations()
    {
        $oldRelations = [];
        foreach ($this->_relations as $relationName) {
            $oldRelations[$relationName] = $this->getOldRelation($relationName);
        }
        return $oldRelations;
    }
1133841
protected function getCleanLog(Model $Model)
	{
		$ds = $Model->getDataSource();
		$queries = array();

		if (method_exists($ds, 'getLog')) {
			$log = $ds->getLog(false, false);
			$diff = Set::diff($log['log'], $this->cachedQueries);

			$this->cachedQueries = $log['log'];

			foreach ($diff as $entry) {
				if (empty($entry['affected'])) {
					continue;
				}

				$queries[] = $entry['query'];
			}
		}

		return $queries;
	}
649894
private function _getJunctionTableColumns($relationName, $model)
    {
        $junctionTableColumns = [];
        if (array_key_exists($relationName, $this->_relationsExtraColumns)) {
            if (is_callable($this->_relationsExtraColumns[$relationName])) {
                $junctionTableColumns = $this->_relationsExtraColumns[$relationName]($model);
            } elseif (is_array($this->_relationsExtraColumns[$relationName])) {
                $junctionTableColumns = $this->_relationsExtraColumns[$relationName];
            }
            if (!is_array($junctionTableColumns)) {
                throw new RuntimeException(
                    'Junction table columns definition must return an array, got ' . gettype($junctionTableColumns)
                );
            }
        }
        return $junctionTableColumns;
    }
456219
public function getList(Model $model) {
        return $model->find('list', array(
            'order' => array($model->alias . '.' . $model->displayField => 'ASC'),
            'cache' => $model->alias . '::getList',
            'cacheExpires' => $this->getExpiration($model)
        ));
    }
752394
public function getModelCacheKeys(Cacheable $model)
    {
        // Build list of cache keys we need to clear.
        $cacheKeys = [
            implode(':', [$model->getTable(), 'index']),
        ];

        // If the model has an primary key add the cache key.
        if (!empty($model->getPrimaryKeyValue())) {
            $cacheKeys[] = implode(':', [$model->getTable(), $model->getPrimaryKeyValue()]);
        }

        // Add the cache keys for the model attributes.
        $this->addAttributeCacheKeys($cacheKeys, $model);

        return $cacheKeys;
    }
87027
public function getAttributes($model)
    {
        $this->model = $model;
        $this->attributes = self::buildRelationshipAttributes($this->model);
        $this->attributes = $this->attributes + self::buildAttributes($this->model);

        return $this->attributes;
    }
845824
public function associate($model)
    {
        $this->parent->setAttribute(
            $this->foreignKey, $model instanceof Model ? $model->getKey() : null
        );

        $this->parent->setAttribute(
            $this->morphType, $model instanceof Model ? $model->getMorphClass() : null
        );

        return $this->parent->setRelation($this->relationName, $model);
    }
25196
protected function getSoftDeleteMethods($model)
    {
        $traits = class_uses(get_class($model), true);
        if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) {
            $this->setMethod('forceDelete', 'bool|null', []);
            $this->setMethod('restore', 'bool|null', []);

            $this->setMethod('withTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
            $this->setMethod('withoutTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
            $this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
        }
    }
597315
protected function determineRelations()
    {
        if (count($this->parameters)) {
            return $this->parameters;
        }

        if ( ! ($info = $this->getModelInformation())) {
            return [];
        }

        return array_pluck($info->relations, 'method');
    }
535304
protected function getTableAndDatabase($model)
    {
        $table = $model->getConnection()->getTablePrefix() . $model->getTable();

        $database = null;

        if (strpos($table, '.')) {
            list($database, $table) = explode('.', $table);
        }

        return [$table, $database];
    }
769457
protected function _getAliases(Model $Model) {
		$aliases = array_merge(array(
			//$Model->name,
			$Model->alias
				), $this->config[$Model->alias]['aliases']
		);

		foreach ($Model->associations() as $associationType) {
			foreach ($Model->$associationType as $associationKey => $association) {
				if ($association['className'] === $Model->name) {
					$aliases[] = $associationKey;
				}
			}
		}

		return $aliases;
	}
1048576
public function parentModel()
    {
        if ($this->value
            && ($relation = $this->guessRelation())
            && ($model = $this->getModel())
            && method_exists($model, $relation)) {
            return $model->$relation;
        }
    }
94032
public function getRelationDictionary(string $relationName): array
    {
        return $this->models
            ->mapWithKeys(
                function (Model $model) use ($relationName) {
                    return [$this->buildKey($model->getKey()) => $model->getRelation($relationName)];
                }
            )->all();
    }