Get an array representing the properties of a model.

@param \Illuminate\Database\Eloquent\Model $model

@return array
488963
public static function castModel(Model $model)
    {
        $attributes = array_merge(
            $model->getAttributes(),
            $model->getRelations()
        );

        $visible = array_flip(
            $model->getVisible() ?: array_diff(array_keys($attributes), $model->getHidden())
        );

        $results = [];

        foreach (array_intersect_key($attributes, $visible) as $key => $value) {
            $results[(isset($visible[$key]) ? Caster::PREFIX_VIRTUAL : Caster::PREFIX_PROTECTED).$key] = $value;
        }

        return $results;
    }
990015
public static function model($model, $value, $key = 'id')
    {
        if (! $model instanceof Builder) {
            $model = $model::query();
        }

        return $model->get()->map(function ($model) use ($value, $key) {
            return [
                'value' => $model->{$key},
                'label' => $model->{$value},
            ];
        });
    }
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;
    }
1213491
public function getColumnsNames(array $columns, $model = null): array
    {
        return array_map(function ($column) use ($model) {
            return $this->getColumnName($column, $model);
        }, $columns);
    }
48841
private function queryAttributes(Model $model)
    {
        $data = [
            'user_id'    => user()->id,
            'namespace'  => get_class($model),
            'foreign_id' => $model->id
        ];
        (is_null($this->field)) ? array_set($data, 'field_class', get_called_class()) : array_set($data, 'field_id', $this->field->id);
        return $data;
    }
569186
private function getPermissionsByModel(string $model) : array
    {
        $table = TableRegistry::getTableLocator()->get('RolesCapabilities.Capabilities');
        Assert::isInstanceOf($table, CapabilitiesTable::class);

        $groups = $table->getUserGroups($this->user['id']);

        $query = TableRegistry::getTableLocator()->get('RolesCapabilities.Permissions')
            ->find('all')
            ->select('foreign_key')
            ->where([
                // WARNING: this might conflict with APP table's name matching a plugin's table name
                'model' => $model,
                'type IN ' => ['view'],
                'OR' => [
                    ['owner_foreign_key IN ' => array_keys($groups), 'owner_model' => 'Groups'],
                    ['owner_foreign_key' => $this->user['id'], 'owner_model' => 'Users']
                ]
            ])
            ->applyOptions(['accessCheck' => false]);

        $result = [];
        foreach ($query->all() as $permission) {
            $result[] = $permission->get('foreign_key');
        }

        return $result;
    }
625509
private function getNodeValues($model)
    {
        $attribute = "{$this->name}_uc_first";
        return [
            'id'        => $model->id,
            'parent'    => $model->parent_id,
            'name'      => $model->$attribute,
            'level'     => $model->depth,
            'type'      => $model->isLeaf() ? 'file' : 'folder'
        ];
    }
104031
public function getCount(Model $model) {
        return $model->find('count', array(
            'cache' => $model->alias . '::getCount',
            'cacheExpires' => $this->getExpiration($model)
        ));
    }
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;
    }
324946
protected function getModel($model) {
		$args = func_get_args();
		array_shift($args);
		require 'app/models/' . $model . '.php';
       	$class = 'Tadpole\model\\' . $model;
		if(!empty($args)) {
			$modData = new ReflectionClass($class);
			$returnMod = $modData->newInstanceArgs($args);
			return $returnMod;
		} else {
        	$returnMod = new $class;
			return $returnMod;
		}
	}
347539
protected static function encryptAttributes(Model $model)
    {
        foreach (static::getEncryptedAttributes() as $attribute) {
            try {
                $model->$attribute = static::getEncrypter()->encrypt($model->$attribute);
            } catch (EncryptException $e) {
            }
        }

        return $model;
    }
456219
public function getList(Model $model) {
        return $model->find('list', array(
            'order' => array($model->alias . '.' . $model->displayField => 'ASC'),
            'cache' => $model->alias . '::getList',
            'cacheExpires' => $this->getExpiration($model)
        ));
    }
1049648
public function getModelLinks(Model $model) {
        $models = Configure::read('Admin.modelLinks');

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

        return array();
    }
382857
public function transform(Timeslot $model)
    {
        return [
            'id'         => (int) $model->id,

            /* place your other model properties here */

            'created_at' => $model->created_at,
            'updated_at' => $model->updated_at
        ];
    }
25196
protected function getSoftDeleteMethods($model)
    {
        $traits = class_uses(get_class($model), true);
        if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) {
            $this->setMethod('forceDelete', 'bool|null', []);
            $this->setMethod('restore', 'bool|null', []);

            $this->setMethod('withTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
            $this->setMethod('withoutTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
            $this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
        }
    }
1135693
public function transform(\Orm\Model $model)
	{
		$properties = $model->list_properties();

		$data = $model->to_array(false, false, true);
		$data = Arr::subset($data, array_keys($properties));
		$data = Arr::flattenAssoc($data, '.');

		// Check for options and set value
		foreach ($properties as $key => $value)
		{
			if ( ! empty($data) and $options = Arr::get($value, 'options', false))
			{
				$data[$key] = $options[$data[$key]];
			}
		}

		if ($this->actions)
		{
			$data['action'] = $this->actions($model);
		}

		return array_values($data);
	}
383107
public function getAll(Model $model) {
        return $model->find('all', array(
            'order' => array($model->alias . '.' . $model->displayField => 'ASC'),
            'cache' => $model->alias . '::getAll',
            'cacheExpires' => $this->getExpiration($model)
        ));
    }