Get the rank weight label for a given field.

@param \Illuminate\Database\Eloquent\Model $model
@param string $field
@return string
171581
protected function rankFieldWeightLabel(Model $model, $field)
    {
        $label = $this->option($model, "rank.fields.$field");

        return collect(['A', 'B', 'C', 'D'])
            ->contains($label) ? $label : '';
    }
217029
protected function getReference(Model $model)
    {
        $reference = $this->getReferenceValue($model);

        return $this->wrapReference($reference);
    }
383625
public static function getModelClassNameQualifiedOrNull(string $model)
    {
        $classNameOverride = vsprintf(self::FORMAT_QUALIFIED_OVERRIDE_TYPE, [$model]);
        $classNameModel = vsprintf(self::FORMAT_QUALIFIED_MODEL_TYPE, [$model]);
        $classNameObject = vsprintf(self::FORMAT_QUALIFIED_OBJECT_TYPE, [$model]);

        if (static::isClassSubClassOfBunqModel($classNameOverride)) {
            return $classNameOverride;
        } elseif (static::isClassSubClassOfBunqModel($classNameModel)) {
            return $classNameModel;
        } elseif (static::isClassSubClassOfBunqModel($classNameObject)) {
            return $classNameObject;
        } else {
            return null;
        }
    }
811447
def get_model_field_label_and_value(instance, field_name) -> (str, str):
    
    label = field_name
    value = str(getattr(instance, field_name))
    for f in instance._meta.fields:
        if f.attname == field_name:
            label = f.verbose_name
            if hasattr(f, 'choices') and len(f.choices) > 0:
                value = choices_label(f.choices, value)
            break
    return label, force_text(value)
375519
private function getValue($item, $model)
    {
        if (is_string($item)) {
            if ($model instanceof Model) {
                if (isset($model->{$item})) {
                    return $model->{$item};
                }
                return $item;
            } else {
                if (isset($model[$item])) {
                    return $model[$item];
                }
                return $item;
            }
        } else if (is_callable($item)) {
            return call_user_func($item, $model);
        }
        return '';
    }
286699
public function getQualifiedFieldName($field)
	{
		$tbl = ($this->getTableAlias() ? $this->getTableAlias() : $this->getTableName());
		return $tbl . '.' . $field;
	}
1319385
public function getFieldType($field)
    {
        $type = 'Line';

        // if form field type explicitly set in models UI properties
        if (isset($field->ui['display'])) {
            $tmp = $field->ui['display'];
            if (isset($tmp['form'])) {
                $tmp = $tmp['form'];
            }
            if (is_string($tmp) && $tmp) {
                return $tmp;
            }
        }

        // associate hasOne (Reference_One) fields with DropDown form field
        if ($this->model->hasRef($field->short_name)) {
            return 'DropDown';
        }

        // associate enum fields with DropDown form_field
        if (isset($field->enum) && $field->type != 'boolean') {
            return 'DropDown';
        }

        // try to find associated form field type
        if (isset($this->type_associations[$field->type])) {
            $type = $this->type_associations[$field->type];
        }

        return $type;
    }
932607
public function getFieldName($field, $modelName)
    {
        if (isset($this->_unionMapsTo[$modelName][$field])) {
            return $this->_unionMapsTo[$modelName][$field];
        }

        return $field;
    }
224381
protected function getReference(Model $model)
    {
        $reference = $this->getReferenceValue($model);

        return $this->wrapWithLink($reference, $this->getLinkForReferenceModel($model));
    }
1266819
protected function getField($field)
    {
        foreach ($this->getFields() as $annotatedField) {
            if ($annotatedField->name === $field) {
                return $annotatedField;
            }
        }

        return null;
    }
94519
public static function adminFormFieldLabel($field) {

        // Does the field have an alternate name?
        $name = $field['name'];

        if (!empty($field['alternate_form_name'])) {
            $name = $field['alternate_form_name'];
        } 

        if ($name == "id") return "ID";

        $html = str_replace("_", " ", $name);
        $html = ucwords($html);
        return $html;
    }
445416
protected function getValueFromModel($model)
    {
        if ( ! ($model instanceof Model)) {
            return null;
        }

        return get_class($model)
             . static::CLASS_AND_KEY_SEPARATOR
             . $model->getKey();
    }
267113
public function getIndexGridColumns($model, $fields)
    {
        $id = Yii::$app->request->getQueryParam('id');
        $relationName = Yii::$app->request->getQueryParam('relation');
        $multiple = Yii::$app->request->getQueryParam('multiple', 'true') === 'true';
        foreach ($fields as $key => $field) {
            if (((is_array($field) || (!is_string($field) && is_callable($field))) && $key === $relationName)
                || $field === $relationName
            ) {
                unset($fields[$key]);
            }
        }
        return array_merge([
            [
                'class'         => 'yii\grid\CheckboxColumn',
                'multiple'      => $multiple,
                'headerOptions' => ['class' => 'column-serial'],
                'checkboxOptions' => function ($model, $key, $index, $column) use ($id, $relationName) {
                    /** @var \yii\db\ActiveRecord $model */
                    $options = [
                        'value' => is_array($key)
                            ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
                            : $key,
                    ];
                    if (empty($relationName) || $model->$relationName === null || trim($id) === '') {
                        return $options;
                    }
                    $relation = $model->getRelation($relationName);
                    if ($relation->multiple) {
                        /** @var \yii\db\ActiveRecord $relationClass */
                        $relationClass = $relation->modelClass;
                        if (Action::importKey($relationClass::primaryKey(), $id)
                            === $model->getAttributes(array_keys($relation->link))
                        ) {
                            $options['checked']  = true;
                            $options['disabled'] = true;
                        }
                    } elseif (Action::exportKey($relation->one()->getPrimaryKey()) === $id) {
                        $options['checked']  = true;
                        $options['disabled'] = true;
                    }
                    return $options;
                },
            ],
            [
                'class'         => 'yii\grid\SerialColumn',
                'headerOptions' => ['class' => 'column-serial'],
            ],
        ], self::getGridColumns($model, $fields));
    }
555053
def get_model_label(model):
    
    if isinstance(model, six.string_types):
        return model
    else:
        return "%s.%s" % (
            model._meta.app_label,
            model.__name__
        )
629093
public static function fieldToColumnName($field)
    {
        $model_name = get_class(new static());
        if (property_exists($model_name, 'graph_node_field_aliases')
            && isset(static::$graph_node_field_aliases[$field])) {
            return static::$graph_node_field_aliases[$field];
        }

        return $field;
    }
421989
public function handleM2MField(Model $model, Field $field)
    {
        $vals = [];
        /** @var $field ManyToManyField */
        if ($field->relation->through->getMeta()->autoCreated) {
            //todo handle natuaral keys
            $m2mValues = function (Model $model) {
                return $model->getPkValue();
            };

            foreach ($model->{$field->getName()}->all() as $item) {
                $vals[] = $m2mValues($item);
            }
        }
        $this->_fields[$field->getName()] = $vals;
    }
166720
protected function getPath($model, $path)
    {
        $name = Str::lower(str_replace('\\', '_', $model));

        return $path.'/'.$name.'.php';
    }