Get the cache key for the given model's cache type.

@param  \Illuminate\Database\Eloquent\Model  $model
@param  string  $type
@param  bool  $allowed
@return string
766059
protected function getCacheKey(Model $model, $type, $allowed = true)
    {
        return implode('-', [
            $this->tag(),
            $type,
            $model->getMorphClass(),
            $model->getKey(),
            $allowed ? 'a' : 'f',
        ]);
    }
117590
protected function keyForScope( $model )
	{
		return implode( '-', array_map( function ( $column ) use ( $model )
		{
			$value = $model->getAttribute( $column );

			if ( is_null( $value ) )
				return 'NULL';

			return $value;
		}, $model->getScopedColumns() ) );
	}
1053983
public static function AllowedSortFields($Allowed = NULL) {
      if (is_array($Allowed)) {
         self::$AllowedSortFields = $Allowed;
      }
      
      return self::$AllowedSortFields;
   }
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;
	}
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);
    }
1193539
public static function findPreviousElement(Model $model, $type=null)
	{
		if($type === null) {
			$type = $model->getType();
		}

		$column = array('pid=?', 'ptable=?', 'type=?', 'sorting<?');
		$values = array($model->pid, $model->ptable, $model->getTypeName($type), $model->sorting);

		return \ContentModel::findOneBy($column, $values);
	}
963074
public function relatedKey($key, $model = false)
    {
        if (!$model) {
            $model = $this->model;
        }

        if (($methodBreaker = strpos($key, '.')) !== false) {
            $method = substr($key, 0, $methodBreaker);
            if (method_exists($model, $method)) {
                if (method_exists($model->$method, $submethod = str_replace($method.'.', '', $key))) {
                    return $model->$method->$submethod();
                }

                if (isset($model->$method->$submethod)) {
                    return $model->$method->$submethod;
                }

                return $model->getRelationValue($method);
            }
        }

        return false;
    }
445416
protected function getValueFromModel($model)
    {
        if ( ! ($model instanceof Model)) {
            return null;
        }

        return get_class($model)
             . static::CLASS_AND_KEY_SEPARATOR
             . $model->getKey();
    }
1341870
public static function getModelKeys($model, $includePrimary = true)
    {
        $keys = array_map(function ($foreignKey) {
            array_shift($foreignKey);
            return array_keys($foreignKey);
        }, $model->getTableSchema()->foreignKeys);
        if ($includePrimary) {
            $keys[] = $model->primaryKey();
        }
        return call_user_func_array('array_merge', $keys);
    }
726470
protected static function getEveryoneConstraint($allowed)
    {
        return function ($query) use ($allowed) {
            $permissions = Models::table('permissions');
            $abilities   = Models::table('abilities');
            $prefix      = Models::prefix();

            $query->from($permissions)
                  ->whereRaw("{$prefix}{$permissions}.ability_id = {$prefix}{$abilities}.id")
                  ->where("{$permissions}.forbidden", ! $allowed)
                  ->whereNull('entity_id');

            Models::scope()->applyToRelationQuery($query, $permissions);
        };
    }
501040
private function getGroupKeyForModel(Model $model)
    {
        $key = "";

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

        return $key;
    }
1334127
private function determine( $type, $key_type = false ) {
		if ( ! $key_type && $this->non_scalar_type_exists( $type ) ) {
			return $type;
		}

		if ( $scalar_type = $this->determine_scalar( $type ) ) {
			if ( $key_type && (in_array( $scalar_type, array( 'double', 'boolean' ) )) ) {
				throw new InvalidArgumentException( 'This type is not supported as a key.' );
			}

			return $scalar_type;
		}

		throw new InvalidArgumentException( 'This type does not exist.' );
	}
659687
protected static function decryptAttributes(Model $model)
    {
        foreach (static::getEncryptedAttributes() as $attribute) {
            try {
                if (is_string($model->$attribute)) {
                    $model->$attribute = static::getEncrypter()->decrypt($model->$attribute);
                }
            } catch (DecryptException $e) {
            }
        }

        return $model;
    }
724800
public static function findRelatedElements(Model $model, $type=null)
	{
		if($model->bootstrap_parentId == '' && $model->getType() != $model::TYPE_START) {
			return null;
		}

		$options = array(
			'order' => 'sorting'
		);

		if($type === null) {
			$column   = 'bootstrap_parentId';
			$values[] = $model->id;
		}
		else {
			$column   = array('bootstrap_parentId=? ', 'type=?');
			$values[] = $model->id;
			$values[] = $model->getTypeName($type);

		}

		return \ContentModel::findBy($column, $values, $options);
	}
1095000
private function _get_cache($item, $mode = 'columns', $force = false): ?array
  {
    $cache_name = $this->_db_cache_name($item, $mode);
    if ( $force && isset($this->cache[$cache_name]) ){
      unset($this->cache[$cache_name]);
    }
    if ( !isset($this->cache[$cache_name]) ){
      if ( $force || !($tmp = $this->cache_get($cache_name)) ){
        switch ( $mode ){
          case 'columns':
            $keys = $this->language->get_keys($item);
            $cols = $this->language->get_columns($item);
            if ( \is_array($keys) && \is_array($cols) ){
              $tmp = [
                'keys' => $keys['keys'],
                'cols' => $keys['cols'],
                'fields' => $cols
              ];
            }
            break;
          case 'tables':
            $tmp = $this->language->get_tables($item);
            break;
          case 'databases':
            $tmp = $this->language->get_databases();
            break;
        }
        if ( !\is_array($tmp) ){
          die("Error while creating the cache for the table $item in mode $mode");
        }
        if ( $tmp ){
          $this->cache_set($cache_name, '', $tmp, $this->cache_renewal);
        }
      }
      if ( $tmp ){
        $this->cache[$cache_name] = $tmp;
      }
    }
    return $this->cache[$cache_name] ?? null;
  }
1261263
protected function getPolicyColumn(Model $model)
    {

        $connection = $model->getConnection();
        $table      = $connection->getTablePrefix() . $model->getTable();
        $schema     = $connection->getDoctrineSchemaManager($table);
        $columns    = Cache::remember('keys_' . $table, 30, function() use($model) {
                    return Schema::getColumnListing($model->getTable());
                });


        $column = null;
        foreach (self::$patternedColumns as $name) {
            if (!is_null($column)) {
                break;
            }
            $column = array_search($name, $columns) !== false ? $name : null;
        }
        if (is_null($column)) {
            foreach ($schema->listTableForeignKeys($table) as $foreignKeyConstraint) {
                if ($foreignKeyConstraint->getForeignTableName() !== 'tbl_users') {
                    continue;
                }
                $column = current($foreignKeyConstraint->getLocalColumns());
            }
        }

        return $column;
    }
874866
public function getMeta($key = false, $model = false)
    {
        if ($key === false) {
            return $this->meta()->get();
        }
        if ($meta = $this->meta()->whereKey($key)->first()) {
            return ($model == false) ? $meta->value : $meta;
        }

        return false;
    }