Generates the cache key.

@param QueryCacheBuilder $builder
@param array             $columns

@return string
199262
protected function generateKey(QueryCacheBuilder $builder, array $columns)
    {
        $sql = $builder->select($columns)->toSql();
        $whereClause = serialize($builder->getBindings());

        return sha1($sql.$whereClause);
    }
32027
public function find($key, $columns = ['*'])
    {
        $this->model = $this->model->newQueryWithoutScopes()->findOrFail($key, $columns);

        return $this->model;
    }
684891
public function get($columns = ['*'])
    {
        $builder = $this->prepareQueryBuilder($columns);

        $models = $builder->getModels();

        // If we actually found models we will also eager load any relationships that
        // have been specified as needing to be eager loaded. This will solve the
        // n + 1 query problem for the developer and also increase performance.
        if (count($models) > 0) {
            $models = $builder->eagerLoadRelations($models);
        }

        return $this->related->newCollection($models);
    }
427479
private function remapBuilderColumns(Builder $builder): void {
    if($builder->aggregate === null) {
      if($builder->columns === ['*']) {
        $builder->columns = array_keys($this->to_db);
      }

      if(is_string($builder->columns)) {
        $builder->columns = [$builder->columns];
      }

      $this->remapColumns($builder->columns);
    } else {
      if($builder->aggregate['columns'] == ['*']) {
        return;
      }

      $this->remapColumns($builder->aggregate['columns'], false);
    }
  }
1131553
protected function verifyOuter(SchemaBuilder $builder, AbstractColumn $column)
    {
        foreach ($this->findTargets($builder) as $schema) {
            $outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase());

            if (!$outerTable->hasColumn($column->getName())) {
                //Column is missing
                throw new RelationSchemaException(
                    "Unable to build morphed relation, outer key '{$column->getName()}' "
                    . "is missing in '{$outerTable->getName()}'"
                );
            }

            if ($outerTable->column($column->getName())->phpType() != $column->phpType()) {
                //Inconsistent type
                throw new RelationSchemaException(
                    "Unable to build morphed relation, outer key '{$column->getName()}' "
                    . "has different type in '{$outerTable->getName()}'"
                );
            }
        }
    }
134183
protected function getStatusColumn(Builder $builder)
    {
        if ($builder->getQuery()->joins && count($builder->getQuery()->joins) > 0) {
            return $builder->getModel()->getQualifiedStatusColumn();
        } else {
            return $builder->getModel()->getStatusColumn();
        }
    }
1027488
public function addPrimaryKey($columns)
    {
        $schema = self::SELECT.' EXISTS
                   (
                       '.self::SELECT.' * FROM '.$this->_informationSchema.'.COLUMNS
                       WHERE '.$this->_tableSchema."= '".$this->database."' AND
                       TABLE_NAME ='".$this->tableName."' AND
                       COLUMN_KEY = 'PRI'

                   ) AS has_primary_key;";

        $hasPrimaryKey = $this->_connection->prepare($schema)->execute();

        if ($hasPrimaryKey === true) {
            $query = '';
            $query = self::ALTER_TABLE.'`'.$this->tableName.'` CHANGE
             `'.$this->primaryKey.'` `'.$this->primaryKey.'` INT( 11 ) NOT NULL';
            $primaryKey = $this->_connection->prepare($query)->execute();

            $schemaString = '';
            $schemaString = $this->commands($columns);

            $this->schema = static::ALTER_TABLE.' `'.$this->database.'`.`'.$this->tableName.'` DROP PRIMARY KEY,
                ADD CONSTRAINT PK_'.strtoupper($this->tableName).'_ID
                PRIMARY KEY ('.$schemaString.')';
        } else {
            $this->schema = static::ALTER_TABLE.' `'.$this->database.'`.`'.$this->tableName.'` ADD
            '.'PRIMARY KEY ('.$columns.')';
        }

        return $this;
    }
278024
private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options) : string
    {
        if (empty($options['primary'])) {
            return '';
        }

        $keyColumns = array_unique(array_values($options['primary']));

        foreach ($keyColumns as $keyColumn) {
            if (! empty($columns[$keyColumn]['autoincrement'])) {
                return '';
            }
        }

        return ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
    }
1312102
public function sqlFetchColumn(string $sql, array $params = [], string $column = '0')
    {
        $stmt = $this->prepare($sql, $params);

        if (ctype_digit((string) $column)) {
            return $stmt->fetchColumn($column);
        }

        if ($record = $stmt->fetch()) {
            return array_key_exists($column, $record) ? $record[$column] : null;
        }

        return null;
    }
410198
public function getCountForPagination($columns = ['*'])
    {
        $result = $this->getBuilder()->getCountForPagination($columns);

        // Reset query builder
        $this->resetBuilder();

        return $result;
    }
647051
public function preSave($builder)
    {
        $const = $builder->getColumnConstant($this->getColumnForParameter('slug_column'));
        $script = "
if (\$this->isColumnModified($const) && \$this->{$this->getColumnGetter()}()) {
    \$this->{$this->getColumnSetter()}(\$this->makeSlugUnique(\$this->{$this->getColumnGetter()}()));";
        if ('true' === $this->getParameter('permanent')) {
            $script .= "
} elseif (!\$this->{$this->getColumnGetter()}()) {
    \$this->{$this->getColumnSetter()}(\$this->createSlug());
}";
        } else {
            $script .= "
} else {
    \$this->{$this->getColumnSetter()}(\$this->createSlug());
}";
        }

        return $script;
    }
179596
public function get($columns = ['*'])
    {
        $cacheKey = $this->generateCacheKey();

        if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) {
            $results = parent::get($columns);

            if ($this->isTimeAwareQuery) {
                // Cache results for $cacheLifeTime minutes
                $this->cache->tags($this->cacheTag)->put($cacheKey, $results, $this->cacheLifeTime);
            } else {
                // Cache results forever
                $this->cache->tags($this->cacheTag)->forever($cacheKey, $results);
            }
        }


        return $results;
    }
1150602
private function get_cache_key( array $products ) {
		$products_string = '';

		foreach ( $products as $product ) {
			$products_string .= $product->get_item_name();
		}

		return md5( self::YST_SEO_SUPPORT_IDENTIFY . $products_string );
	}
292676
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
    {
        if ($parentQuery->getQuery()->from == $query->getQuery()->from) {
            return $this->getRelationExistenceQueryForSelfRelation($query, $parentQuery, $columns);
        }

        $this->performJoin($query);

        return $query->select($columns)->whereColumn(
            $this->getQualifiedForeignKeyName(), '=', $this->getQualifiedSecondOwnerKeyName()
        );
    }
19893
public function buildSqlQuery(IndexQueryInterface $query, array $columns = null)
    {
        $queryString = sprintf("SELECT `%s` FROM `%s`", implode("`,`", $columns), $query->getName());

        if ("" !== $criteria = $this->buildSqlConditions($query)) {
            $queryString .= sprintf(" WHERE %s", $criteria);
        }

        if (null !== $limit = $query->getLimit()) {
            $queryString .= sprintf(" LIMIT %d", $limit);
        }

        return $queryString;
    }
143700
public function key($type, $columns, $name)
		{
			$parameters = array('name' => $name, 'columns' => (array) $columns);

			return $this->command($type, $parameters);
		}
736998
protected function generateCacheKey()
    {
        $bindings = array_map(function ($param) {

            // Round datetime
            if ($param instanceof \DateTime) {
                $this->isTimeAwareQuery = true;
                return $this->getRoundedDateTime($param);
            }

            return $param;

        }, $this->getBindings());


        return sha1($this->connection->getName() . $this->toSql() . serialize($bindings));
    }