Renders a display value to print to the list view.

@param Model $model
@param mixed $source     source column, method name or value
@return string
765983
public function render(Model $model, $source)
    {
        $source = $this->resolveModelSource($model, $source);

        if ($this->interpretAsBoolean($source)) {
            return '<i class="fa fa-check text-success" title="' . e(cms_trans('common.boolean.true')) . '"></i>';
        }

        return '<i class="fa fa-times text-danger" title="' . e(cms_trans('common.boolean.false')) . '"></i>';
    }
835194
public function retrieve(Model $model, $source)
    {
        $data = [
            'longitude' => null,
            'latitude'  => null,
            'location'  => null,
        ];

        if ($latitude = $this->getAttributeLatitude()) {
            $data['latitude'] = (float) parent::retrieve($model, $latitude);
        }

        if ($longitude = $this->getAttributeLongitude()) {
            $data['longitude'] = (float) parent::retrieve($model, $longitude);
        }

        if ($text = $this->getAttributeText()) {
            $data['location'] = parent::retrieve($model, $text);
        }

        return $data;
    }
1372647
protected function render($template, $model)
    {
        $twig = $this->getTwig();

        return $twig->render($template, $model);
    }
169994
public function render(ModelConfigurationInterface $model, $content, $title = null)
    {
        if ($content instanceof RedirectResponse) {
            return $content;
        }

        if ($content instanceof Renderable) {
            $content = $content->render();
        }

        if (is_null($title)) {
            $title = $model->getTitle();
        }

        return $this->admin->template()->view('_layout.inner')
            ->with('title', $title)
            ->with('content', $content)
            ->with('breadcrumbKey', $this->parentBreadcrumb);
    }
431149
protected function showDetail(Model $model)
    {
        $name = $this->manager->getClassName($model);

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

        $summary = $this->manager->getModelSummary($name);
        $rows = [];

        foreach ($summary as $key => $value) {
            if (is_bool($value)) {
                $value = $value ? 'yes' : 'no';
            }

            $valueText = $this->paintString($value, 'brown');

            $rows[] = [$key, $valueText];
        }

        $this->table(['Key', 'Value'], $rows);

        $this->showDatabaseFields($model);
        $this->showRelatoins($model);
        $this->showModifier($model);
    }
290356
public function formatOutputRecord($data, $model=null)
    {
        $model = $model ? : $this;
        
        if (!$data || !isset($model['primary_key']) || !isset($model['fields'])) {
            return $data;
        }
        
        $fields_names = array_keys($model['fields']);
        foreach ($data as $k => $v){
            if (in_array($k, $fields_names)) {
                $data[$k] = FieldOutputHandler::formatValue($model['fields'][$k], $v);
            }
        }
        
        return $data;
    }
1073221
public function render(Model $model, $source)
    {
        $relation = $this->getActualNestedRelation($model, $source);

        $count = $this->getCount($relation);

        if ( ! $count) {
            return '<span class="relation-count count-empty">&nbsp;</span>';
        }

        if ( ! $this->listColumnData) {
            throw new RuntimeException('List column data must be set');
        }

        // Use the options or relation to get the relevant context for the link
        $relationMethod = array_get($this->listColumnData->options(), 'relation');
        $modelClass     = array_get($this->listColumnData->options(), 'model', get_class($relation->getRelated()));

        if ( ! $relationMethod) {
            throw new RuntimeException(get_class($this) . ' requires option.relation to be set!');
        }

        $childrenName = $this->getVerboseChildrenName($modelClass);

        if ($this->isMorphToRelation($modelClass, $relationMethod)) {
            $parentIndicator = $this->getMorphTypeForModel($model) . ':' . $model->getKey();
        } else {
            $parentIndicator = $model->getKey();
        }

        return view(static::VIEW, [
            'count'        => $count,
            'link'         => $this->getChildrenLink($parentIndicator, $relationMethod, $modelClass),
            'childrenName' => $childrenName,
        ]);
    }
797962
protected function getReferenceSource(Model $model, $source = null)
    {
        if (null === $source) {
            // Get model information for the model
            $information = $this->getInformationRepository()->getByModel($model);

            if ($information && $information->reference->source) {
                $source = $information->reference->source;
            }
        }

        if ( ! $source) return null;

        return $source;
    }
183801
public function display(string $fieldname, $value, string $model = null)
    {
        $value = $value === true ? 'true' : 'false';

        return $value;
    }
141789
protected function determineTargetModelFromSource($modelClass, $source)
    {
        if ( ! is_a($modelClass, Model::class, true)) {
            // @codeCoverageIgnoreStart
            throw new UnexpectedValueException("{$modelClass} is not an Eloquent model");
            // @codeCoverageIgnoreEnd
        }

        $model = new $modelClass;

        if ( ! ($relation = $this->getNestedRelation($model, $source))) {
            // @codeCoverageIgnoreStart
            $relation = $this->resolveModelSource($model, $source);
            // @codeCoverageIgnoreEnd
        }

        if ( ! ($relation instanceof Relation)) {
            // @codeCoverageIgnoreStart
            throw new UnexpectedValueException(
                "Source {$source} on {$modelClass} does not resolve to an Eloquent relation instance"
            );
            // @codeCoverageIgnoreEnd
        }

        /** @var Relation $relation */
        return $relation->getRelated();
    }
1074390
public function executeGetColumnData($model, $params = [])
	{
		$value = null;
		if (isset($params['value']) && $params['value'] !== null) {
			if (is_string($params['value'])) {
				$value = ArrayHelper::getValue($model, $params['value']);
			} else {
				$value = call_user_func($params['value'], $model, $this);
			}
		} elseif (isset($params['attribute']) && $params['attribute'] !== null) {
			$value = ArrayHelper::getValue($model, $params['attribute']);
		}

		if (isset($params['format']) && $params['format'] != null)
			$value = $this->formatter()->format($value, $params['format']);

		return $value;
	}
55961
public function performStoreAfter(Model $model, $source, $value)
    {
        $relation = $this->resolveModelSource($model, $source);

        if ( ! ($relation instanceof Relation)) {
            throw new UnexpectedValueException("{$source} did not resolve to relation");
        }

        // Any singular relations are unexpected
        if (    $relation instanceof BelongsTo
            ||  $relation instanceof HasOne
            ||  $relation instanceof MorphOne
        ) {
            throw new UnexpectedValueException("{$source} is a single relation, expecting plural");
        }

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

        // Should not be used, since this is for singular relations..
        if ($relation instanceof BelongsToMany) {
            $relation->sync($value);
            return;
        }

        // For *One and *Many relations, we need to handle detachment for currently related models.
        if (    $relation instanceof HasOne
            ||  $relation instanceof HasMany
            ||  $relation instanceof MorphOne
            ||  $relation instanceof MorphMany
        ) {
            // Detach only the models that shouldn't stay attached (ie. aren't in the new value array)

            /** @var Collection|Model[] $currentlyRelated */
            $currentlyRelated = $relation->get();
            $currentlyRelated = $currentlyRelated->filter(function (Model $model) use ($value) {
                return ! in_array($model->getKey(), $value);
            });

            $this->detachRelatedModelsForOneOrMany($currentlyRelated, $relation);
        }

        // For HasMany, the related models must be found,
        // and then they should be saved on the relation.
        $relatedModels = $this->getModelsByKey($relation->getRelated(), $value);

        if ( ! count($relatedModels)) return;

        if (    $relation instanceof HasOne
            ||  $relation instanceof HasMany
            ||  $relation instanceof MorphOne
            ||  $relation instanceof MorphMany
        ) {
            foreach ($relatedModels as $relatedModel) {
                $relation->save($relatedModel);
            }
            return;
        }

        throw new UnexpectedValueException(
            'Unexpected relation class ' . get_class($relation) . " for {$source}"
        );
    }
1279791
public function getRecordList(Model $model) {
        if ($model->hasMethod('generateTreeList')) {
            return $model->generateTreeList(null, null, null, ' -- ');

        } else if ($model->hasMethod('getList')) {
            return $model->getList();
        }

        return $model->find('list', array(
            'order' => array($model->alias . '.' . $model->displayField => 'ASC')
        ));
    }
1116469
public function retrieve(Model $model, $source)
    {
        if ($this->isTranslated()) {
            return $model->translations->pluck($source, config('translatable.locale_key', 'locale'))->toArray();
        }

        return $this->resolveModelSource($model, $source);
    }
813212
public function render(Model $model, $source)
    {
        $source = $this->resolveModelSource($model, $source);

        if ( ! ($source instanceof AttachmentInterface)) {
            throw new UnexpectedValueException("Paperclip strategy expects Attachment as source");
        }

        $resize = $this->getVarianttoUse($source);

        if ($this->listColumnData) {
            $width  = array_get($this->listColumnData->options, 'width');
            $height = array_get($this->listColumnData->options, 'height');
        } else {
            $width  = null;
            $height = null;
        }

        return view(static::VIEW, [
            'exists'      => $source->size() > 0,
            'filename'    => $source->originalFilename(),
            'urlThumb'    => $source->url($resize),
            'urlOriginal' => $source->url(),
            'width'       => $width ?: $height ?: static::WIDTH,
            'height'      => $height ?: $width ?: static::HEIGHT,
        ]);
    }
1154807
public function renderField(Model $model, $attribute, array $settings = [])
    {
        $fieldOptions = ArrayHelper::getValue($settings, 'fieldOptions', []);
        $field = $this->field($model, $attribute, $fieldOptions);

        if (($label = ArrayHelper::getValue($settings, 'label')) !== null) {
            $field->label($label, ArrayHelper::getValue($settings, 'labelOptions', []));
        }
        if (($hint = ArrayHelper::getValue($settings, 'hint')) !== null) {
            $field->hint($hint, ArrayHelper::getValue($settings, 'hintOptions', []));
        }

        $type = ArrayHelper::getValue($settings, 'type', static::INPUT_TEXT);
        $this->prepareField($field, $type, $settings);

        return $field;
    }
33297
private function assign(Source $source, string $presentationModel): void
    {
        if (isset($this->presentationModels[$source])) {
            throw new ModelAlreadyAssignedException("A presentation model has already been assigned to {$source->getName()}");
        }

        $this->presentationModels[$source] = $presentationModel;
    }