return model fields in proper way.

@param $record
@param $col

@return mixed
775338
public function renderTableRow($record, $col)
    {
        switch (array_get($col, 'type', 'text')) {
            case 'yes_no':
                return $record->yes_no($record->{$col['db_field']});
                break;
            case 'format_default_date':
                return $record->formatDefaultData($record->{$col['db_field']});
                break;
            case 'sort':
                return '<div class="fa fa-sort sortable-handle"></div>';
                break;
            case 'relation':
                return $record->{$col['relation']}->{$col['db_field']};
                break;
            case 'translation':
                $locale = config('app.locale', 'en');
                $i18n = I18n::select('id')->where('locale', $locale)->first();
                if ($i18n) {
                    $i18nId = $i18n->id;

                    return $record->translate(1)->{$col['db_field']};
                }

                return 'No translation';
                break;
            default:
                return $record->{$col['db_field']};
                break;
        }
    }
1161339
public function getColumnContent($gridField, $record, $columnName) {
        if(!$record->canView()) return;

        $field = GridField_FormAction::create($gridField, 'ExportSingle'.$record->ID, false,
                "exportsingle", array('RecordID' => $record->ID))
            ->addExtraClass('gridfield-button-export-single no-ajax')
            ->setAttribute('title', _t('firebrandhq.EXCELEXPORT', "Export"))
            ->setAttribute('data-icon', 'download-csv');
        return $field->Field();
    }
1013090
public static function fromRecord($record)
    {
        if (!$record) {
            return null;
        }
        $className = get_called_class();
        $entity = new $className;
        foreach ($record as $key => $value) {
            $entity->$key = $value;
        }
        return $entity;
    }
1079743
public function getEntityById($entity, $id, $cols = null)
    {
        $tbl = $this->_resource->getTableName($entity);
        /* columns to select */
        $cols = ($cols) ? $cols : '*';
        $query = $this->_conn->select();
        $query->from($tbl, $cols);
        foreach (array_keys($id) as $field) {
            $query->where("`$field`=:$field");
        }
        $result = $this->_conn->fetchRow($query, $id);
        return $result;
    }
743168
protected function processRecord(array $record): array
    {
        if ($this->processors) {
            foreach ($this->processors as $processor) {
                $record = PhpHelper::call($processor, $record);
            }
        }

        return $record;
    }
625981
protected function _getRecords(array $records, TableSchema $schema)
    {
        $fields = $values = $types = [];
        $columns = $schema->columns();
        foreach ($records as $record) {
            $fields = array_merge($fields, array_intersect(array_keys($record), $columns));
        }
        $fields = array_values(array_unique($fields));
        foreach ($fields as $field) {
            $types[$field] = $schema->column($field)['type'];
        }
        $default = array_fill_keys($fields, null);
        foreach ($records as $record) {
            $values[] = array_merge($default, $record);
        }

        return [$fields, $values, $types];
    }
855215
protected function getRelationColumnValue($columnName, $record)
    {
        list($relationName, $relationColumnName) = getRelationDetails($columnName);

        if ($methodName = $this->customisesColumnValue($relationName.'_'.$relationColumnName)) {
            return $record->$methodName();
        }

        if ($record->$relationName) {
            return $record->$relationName->$relationColumnName;
        }

        return 'N/A';
    }
1083725
public function conditionsFilter(Model $model, $record, $conditions, $or = false) {
		foreach ($conditions as $field => $value) {
			$return = null;
			if ($value === '') {
				continue;
			}
			if (is_array($value) && in_array(strtoupper($field), array('AND', 'NOT', 'OR'))) {
				switch (strtoupper($field)) {
					case 'AND':
						$return = $this->conditionsFilter($model, $record, $value);
						break;
					case 'NOT':
						$return = !$this->conditionsFilter($model, $record, $value);
						break;
					case 'OR':
						$return = $this->conditionsFilter($model, $record, $value, true);
						break;
				}
			} else {
				if (is_array($value)) {
					$type = 'IN';
				} elseif (preg_match('/^(\w+\.?\w+)\s+(=|!=|LIKE|IN|<|<=|>|>=)$/i', $field, $matches)) {
					$field = $matches[1];
					$type = strtoupper($matches[2]);
				} elseif (preg_match('/^(\w+\.?\w+)\s+(=|!=|LIKE|IN|<|<=|>|>=)\s+(.*)$/i', $value, $matches)) {
					$field = $matches[1];
					$type = strtoupper($matches[2]);
					$value = $matches[3];
				} else {
					$type = '=';
				}
				if (strpos($field, '.') !== false) {
					list($alias, $field) = explode('.', $field, 2);
					if ($alias != $model->alias) {
						continue;
					}
				}
				switch ($type) {
					case '<':
						$return = (isset($record[$field]) && $record[$field] < $value);
						break;
					case '<=':
						$return = (isset($record[$field]) && $record[$field] <= $value);
						break;
					case '=':
						$return = (isset($record[$field]) && $record[$field] == $value);
						break;
					case '>':
						$return = (isset($record[$field]) && $record[$field] > $value);
						break;
					case '>=':
						$return = (isset($record[$field]) && $record[$field] >= $value);
						break;
					case '!=':
						$return = (!isset($record[$field]) || $record[$field] != $value);
						break;
					case 'LIKE':
						$value = preg_replace(array('#(^|[^\\\\])_#', '#(^|[^\\\\])%#'), array('$1.', '$1.*'), $value);
						$return = (isset($record[$field]) && preg_match('#^' . $value . '$#i', $record[$field]));
						break;
					case 'IN':
						$items = array();
						if (is_array($value)) {
							$items = $value;
						} elseif (preg_match('/^\(\w+(,\s*\w+)*\)$/', $value)) {
							$items = explode(',', trim($value, '()'));
							$items = array_map('trim', $items);
						}
						$return = (isset($record[$field]) && in_array($record[$field], (array)$items));
						break;
				}
			}
			if ($return === $or) {
				return $or;
			}
		}
		return !$or;
	}
1076168
protected function extractNewestDates($record)
    {
        $result = [];

        if (array_key_exists('md-date', $record['ch'])) {
            foreach ($record['ch']['md-date'] as $date) {
                $dateParts = preg_match_all('/[0-9]{4}/', $date['values'][0], $matches, PREG_SET_ORDER);
                if ($matches && count($matches) > 0) {
                    $parsedDate = $matches[count($matches) - 1][0];
                    if (is_numeric($parsedDate)) {
                        $result[] = (int)$parsedDate;
                    }
                }
            }
        }
        return $result;
    }
1336673
private function resetCraftMatrixFieldBlockTypesCache(Model $record)
    {
        $obj = $record;
        $refObject = new \ReflectionObject($obj);
        if ($refObject->hasProperty('_blockTypes')) {
            $refProperty1 = $refObject->getProperty('_blockTypes');
            $refProperty1->setAccessible(true);
            $refProperty1->setValue($obj, null);
        }
    }
691731
protected function getFormFieldTabs($record, $context = [])
    {
        return TabSet::create(
            'Editor',
            [
                $this->getFormFieldDetailsTab($record, $context),
                $this->getFormFieldSecurityTab($record, $context),
            ]
        );
    }
658811
public function extractType(EntityMetadata $metadata, array $record)
    {
        if (false === $metadata->isPolymorphic()) {
            return $metadata->type;
        }
        return $this->extractField(Persister::POLYMORPHIC_KEY, $record);
    }
318888
private function getNormalisedRecordName(Record $record): string
    {
        return '@' === $record->getName()
            ? $record->getDomain()
            : $record->getName() . '.' . $record->getDomain();
    }
595344
public function findExistingObject($record, $columnMap = [])
    {
        $SNG_objectClass = singleton($this->objectClass);
        // checking for existing records (only if not already found)

        foreach ($this->duplicateChecks as $fieldName => $duplicateCheck) {
            $existingRecord = null;
            if (is_string($duplicateCheck)) {
                // Skip current duplicate check if field value is empty
                if (empty($record[$duplicateCheck])) {
                    continue;
                }

                // Check existing record with this value
                $dbFieldValue = $record[$duplicateCheck];
                $existingRecord = DataObject::get($this->objectClass)
                    ->filter($duplicateCheck, $dbFieldValue)
                    ->first();

                if ($existingRecord) {
                    return $existingRecord;
                }
            } elseif (is_array($duplicateCheck) && isset($duplicateCheck['callback'])) {
                if ($this->hasMethod($duplicateCheck['callback'])) {
                    $existingRecord = $this->{$duplicateCheck['callback']}($record[$fieldName], $record);
                } elseif ($SNG_objectClass->hasMethod($duplicateCheck['callback'])) {
                    $existingRecord = $SNG_objectClass->{$duplicateCheck['callback']}($record[$fieldName], $record);
                } else {
                    user_error("CsvBulkLoader::processRecord():"
                        . " {$duplicateCheck['callback']} not found on importer or object class.", E_USER_ERROR);
                }

                if ($existingRecord) {
                    return $existingRecord;
                }
            } else {
                user_error('CsvBulkLoader::processRecord(): Wrong format for $duplicateChecks', E_USER_ERROR);
            }
        }

        return false;
    }
913394
protected function primaryColumnOf(RecordInterface $record): string
    {
        return $this->orm->define(get_class($record), ORMInterface::R_PRIMARY_KEY);
    }
50332
private function fixBlockFieldsForPreview($record)
    {
        foreach ($record->contenttype['fields'] as $fieldSlug => $fieldSettings) {
            if ($fieldSettings['type'] === 'block') {
                $fieldValue = $this->getBlockFieldValue($record, $fieldSlug);
                if ($fieldValue) {
                    $newArray = [];
                    foreach ($fieldValue as $item) {
                        if (!empty($item)) {
                            foreach ($item as $k => &$v) {
                                $v['block'] = $k;
                            }
                            $newArray[] = $v;
                        }
                    }
                    $this->setFieldValue($record, $fieldSlug, $newArray);
                }
            }
        }

        return $record;
    }
802658
public static function toScalarValues($record)
    {
        return array_map(
            function ($v) {
                if (!is_scalar($v)) {
                    return '<' . gettype($v) . '>';
                }
                return $v;
            },
            (array)$record
        );
    }