Return model alias + all model aliases from model association
(if model have associations with itself)

@param Model $Model
@return array
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;
	}
104031
public function getCount(Model $model) {
        return $model->find('count', array(
            'cache' => $model->alias . '::getCount',
            'cacheExpires' => $this->getExpiration($model)
        ));
    }
694699
public function getTransformedFiles(Model $model) {
        if (isset($this->_uploads[$model->alias])) {
            return $this->_uploads[$model->alias]->getTransformedFiles();
        }

        return array();
    }
423059
private function getDefaultUrls($model)
    {
        $slug = getModelSlug($model);
        return [
            'details'   => lmbRoute("api.{$slug}.detail", ['id' => $model->id]),
            'fast_edit' => lmbRoute("api.{$slug}.fastEdit", ['id' => $model->id]),
            'edit'      => lmbRoute("api.{$slug}.update", ['id' => $model->id]),
            'destroy'   => lmbRoute("api.{$slug}.destroy", ['id' => $model->id]),
            'show'      => lmbRoute("admin.{$slug}.show", ['id' => $model->id])
        ];
    }
681126
protected function getScopeConstraints(Model $model)
    {
        $builder = $model->newQueryWithoutScopes();

        $this->apply($builder, $model);

        return (array) $builder->getQuery()->wheres;
    }
780829
public function getById(Model $model, $id) {
        return $model->find('first', array(
            'conditions' => array($model->alias . '.' . $model->primaryKey => $id),
            'contain' => array_keys($model->belongsTo),
            'cache' => array($model->alias . '::getById', $id),
            'cacheExpires' => $this->getExpiration($model)
        ));
    }
330005
protected function getManualConfig(Model $model)
    {
        if (!method_exists($model, 'xTypeConfig')) {
            return [];
        }

        $config = $model->xTypeConfig();
        $parsed = [];
        $foreignKeys = [];

        foreach ($config as $key=>$rule) {
            if ($rule != 'relation') {
                $parsed[$key] = $rule;
                continue;
            }

            $relation = $this->relationReflector->buildRelationXTypeInfo($model, $key);

            $parsed[$key] = $relation['type'];

            if ($relation['foreign_keys']) {
                $foreignKeys += $relation['foreign_keys'];
            }
        }

        return $parsed;
    }
336901
protected function getCasts(Model $model)
    {
        $class = get_class($model);

        if (!isset($this->castsCache[$class])) {
            $this->castsCache[$class] = Cheat::get($model, 'casts');
        }

        return $this->castsCache[$class];
    }
357056
public function createModelData(Model $model)
    {
        $data = [];

        if ($model->getId()) {
            $data['id'] = $model->getId();
        }
        if ($model->getName()) {
            $data['name'] = $model->getName();
        }
        if ($model->getConcepts()) {
            $data['output_info']['data'] = [];
            $data['output_info']['data'] = $this->addModelConcepts($data['output_info']['data'], $model->getConcepts());
        }
        $data['output_info']['output_config'] = $model->getOutputConfig();

        return $data;
    }
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);
    }
874284
protected function getEagerModelKeys(array $models)
    {
        $keys = array();

        foreach ($models as $model) {
            if (! is_null($value = $model->{$this->foreignKey})) {
                $keys[] = $value;
            }
        }

        if (count($keys) == 0) {
            return array(0);
        }

        return array_values(array_unique($keys));
    }
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;
    }
1003968
public function children( $model )
	{
		$query = $this->model->newQuery();

		$query->where( $this->model->getQualifiedParentColumnName(), '=', $model->getKey() );

		// We must also add the scoped column values to the query to compute valid
		// left and right indexes.
		foreach ( $this->scopedAttributes( $model ) as $fld => $value )
			$query->where( $this->qualify( $fld ), '=', $value );

		$query->orderBy( $this->model->getQualifiedLeftColumnName() );
		$query->orderBy( $this->model->getQualifiedRightColumnName() );
		$query->orderBy( $this->model->getQualifiedKeyName() );

		return $query->get();
	}
187346
protected function getForeignKeyName(Model $model)
    {
        $table = $model->getTable();

        if (array_key_exists($table, $this->foreignKeyLookup)) {
            return $this->foreignKeyLookup[$table];
        }

        return Str::singular($table).'_id';
    }
7292
private function getMutableAttributes($model)
    {
        $attrs = get_object_vars($model);
        unset($attrs[$this->key]);
        
        // remove reference attributes, if any
        if ($model instanceof ManagedModelInterface) {
            foreach (array_keys($model->getReferences()) as $ref) {
                unset($attrs[$ref]);
            }
        }
        
        return $attrs;
    }
103271
protected function appendRelatedModelsToModelData(array $model)
    {
        $relationships = array_merge(
            array_get($model, 'relationships.normal'),
            array_get($model, 'relationships.reverse')
        );

        $model['related_models'] = [];

        foreach ($relationships as $name => $relationship) {

            $relatedModelId = $relationship['model'];

            if (isset($model['related_models'][ $relatedModelId ])) continue;

            $model['related_models'][ $relatedModelId ] = $this->data['models'][ $relatedModelId ];
        }

        return $model;
    }
1299425
protected function parseModel($model)
    {
        if (isset($this->alias[$model])) {
            $model = $this->alias[$model];
        }

        if (false === strpos($model, '\\')) {
            $path = explode('\\', get_class($this->parent));
            array_pop($path);
            array_push($path, Db::parseName($model, 1));
            $model = implode('\\', $path);
        }

        return $model;
    }