Returns model reference string

@param Model  $model
@param string $source
@return string
184073
public function render(Model $model, $source)
    {
        $source = $this->resolveModelSource($model, $source);

        return '#' . $model->getKey() . ': ' . $source;
    }
350131
public function referencing(Model $model)
    {
        $references = [];

        // TODO: SchemaManager should do this
        foreach ($this->schemas as $schema) {
            $references = array_merge($references, $schema->referencing($model->getBlueprint()));
        }

        // TODO: ModelManager should do this
        foreach ($references as &$related) {
            $blueprint = $related['blueprint'];
            $related['model'] = $model->getBlueprint()->is($blueprint->schema(), $blueprint->table())
                ? $model
                : $this->makeModel($blueprint->schema(), $blueprint->table(), false);
        }

        return $references;
    }
1366477
public function getValue($model, $data)
    {
        /** @type Model $model */
        $model = $this->add($this->getModel());
        $id = $data[$this->foreignName];

        try {

            $this->hook('beforeForeignLoad', array($model, $id));

            $model->load($id);
            $titleField = $model->getTitleField();

            return $model->get($titleField) ?: 'Ref#'.$id;
        } catch (BaseException $e) {
            // record is no longer there it seems
            return null;
        }
    }
528823
public function retrieve(Model $model, $source)
    {
        $this->model = $model;

        if ($this->isTranslated()) {

            $keys      = [];
            $localeKey = config('translatable.locale_key', 'locale');

            foreach ($model->translations as $translation) {
                /** @var Relation $relation */
                $relation = $translation->{$source}();

                $keys[ $translation->{$localeKey} ] = $this->getValueFromRelationQuery($relation);
            }

            return $keys;
        }

        $relation = $this->resolveModelSource($model, $source);

        if ( ! ($relation instanceof Relation)) {
            throw new UnexpectedValueException(
                "{$source} did not resolve to a relation for " . get_class($this) . " on " . get_class($model)
            );
        }

        try {
            return $this->getValueFromRelationQuery($relation);

        } catch (\Exception $e) {

            throw new RuntimeException(
                "Exception retrieving relation values for source '{$source}' "
                . "for form field key '{$this->formFieldData->key}'",
                0,
                $e
            );
        }
    }
223456
public function render(Model $model, $source)
    {
        $attachment = $this->resolveModelSource($model, $source);

        if ( ! ($attachment instanceof AttachmentInterface)) {
            return null;
        }

        return $attachment->url();
    }
1251511
public static function get(Model $model)
    {
        return Mention::where('model_type', get_class($model))
            ->where('model_id', $model->getKey())
            ->get();
    }
1350709
protected function makeReferenceStrategy(Model $model)
    {
        // Get model information for the model
        $information = $this->getInformationRepository()->getByModel($model);

        // If the model is not part of the CMS, fall back
        if ( ! $information) return null;

        $strategy = $information->reference->strategy;

        if ( ! $strategy) {
            $strategy = config('cms-models.strategies.reference.default-strategy');
        }

        return $this->makeReferenceStrategyInstance($strategy);
    }
420364
protected function getSlugSource($from): string
    {
        if (is_null($from)) {
            return $this->model->__toString();
        }

        $sourceStrings = array_map(function($key) {
            $value = data_get($this->model, $key);
            if (is_bool($value)) {
                $value = (int) $value;
            }

            return $value;
        }, (array) $from);

        return implode($sourceStrings, ' ');
    }
244141
public static function modelName($project, $location, $model)
    {
        return self::getModelNameTemplate()->render([
            'project' => $project,
            'location' => $location,
            'model' => $model,
        ]);
    }
1049648
public function getModelLinks(Model $model) {
        $models = Configure::read('Admin.modelLinks');

        if (isset($models[$model->qualifiedName])) {
            return $models[$model->qualifiedName];
        }

        return array();
    }
499118
public function render(Model $model, $source)
    {
        return implode($this->getSeparator(), array_map('e', $model->tagNames()));
    }
310550
protected function getModelTable($model)
    {
        if (!is_object($model)) {
            $model = new $model;
        }

        return DB::getTablePrefix().$model->getTable();
    }
501040
private function getGroupKeyForModel(Model $model)
    {
        $key = "";

        foreach ($this->groups as $group) {
            $key .= $model[$group] . "|";
        }

        return $key;
    }
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;
	}
16189
protected function _readMetaData($model)
    {
        $modelName = is_string($model) ? $model : get_class($model);

        if (!isset($this->_metadata[$modelName])) {
            $data = $this->read($modelName);
            if ($data !== false) {
                $this->_metadata[$modelName] = $data;
            } else {
                $modelInstance = is_string($model) ? new $model : $model;

                $data = $this->_di->getShared($modelInstance->getDb(true))->getMetadata($modelInstance->getSource(true));

                $this->_metadata[$modelName] = $data;
                $this->write($modelName, $data);
            }
        }

        return $this->_metadata[$modelName];
    }
224381
protected function getReference(Model $model)
    {
        $reference = $this->getReferenceValue($model);

        return $this->wrapWithLink($reference, $this->getLinkForReferenceModel($model));
    }
315999
public static function getModelName( $model, $bean = null ) {
		if (isset(self::$modelCache[$model])) return self::$modelCache[$model];
		if (self::$modelFormatter){
			$modelID = self::$modelFormatter->formatModel($model,$bean);
		}
		else {
			$modelID = 'Model_'.ucfirst($model);
		}
		self::$modelCache[$model] = $modelID;
		return self::$modelCache[$model];
	}