Get an array with the values of a given column.

@author Morten Rugaard <moru@nodes.dk>

@param  string  $column
@param  string  $key
@return array
17904
public function pluck($column, $key = null)
    {
        $result = $this->getBuilder()->pluck($column, $key);

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

        return $result;
    }
715747
public function pluck($column, $key = null)
    {
        $results = $this->toBase()->pluck($column, $key);

        // If the model has a mutator for the requested column, we will spin through
        // the results and mutate the values so that the mutated version of these
        // columns are returned as you would expect from these Eloquent models.
        if (! $this->model->hasGetMutator($column) &&
            ! $this->model->hasCast($column) &&
            ! in_array($column, $this->model->getDates())) {
            return $results;
        }

        return $results->map(function ($value) use ($column) {
            return $this->model->newFromBuilder([$column => $value])->{$column};
        });
    }
1239951
private function columnToArray(Column $column)
    {
        return array_filter([
            'columnName' => $column->name,
            'length' => $column->length,
            'nullable' => $column->nullable,
            'unique' => $column->unique,
            'options' => $column->options,
            'precision' => $column->precision,
            'scale' => $column->scale,
            'columnDefinition' => $column->columnDefinition,
        ]);
    }
468767
public function col($column)
    {
        $values = [];
        foreach ($this->_entities as $entity) {
            if ($entity->hasAttribute($column)) $values[] = $entity->$column;
        }
        return $values;
    }
464094
public function pluck(string $column, string $keyBy = ''): array
    {
        $pdoStatement = $this->provideStatement();
        $pdoStatement = $this->execute($pdoStatement);
        $rows = $pdoStatement->fetchAll(\PDO::FETCH_ASSOC);
        if (empty($rows)) {
            return [];
        }
        if (!isset($rows[0][$column])) {
            throw new DatabaseException('Column not found in result.');
        }
        if (!empty($keyBy) && !isset($rows[0][$keyBy])) {
            throw new DatabaseException('Column to use as key not found in result.');
        }
        $indexKey = (!empty($keyBy)) ? $keyBy : null;
        return array_column($rows, $column, $indexKey);
    }
977460
public function column($key)
    {
        $result = array_column($this->all(), $key);

        if (empty($result)) {
            $this->each(function ($item) use (&$result, $key) {
                array_push($result, $item->{$key});
            });
        }

        return new static($result);
    }
205469
private function getCondition($column)
    {
        return H::array_first($this->conditions, function ($condition) use ($column) {
            return $condition['column'] === $column;
        });
    }
224299
public function column($column)
    {
        return $this
            ->map(function (CollectionableInterface $entity) use ($column) {
                return $this->getFieldValue($entity, $column);
            })
            ->toArray()
        ;
    }
708354
public function lists($column, $key = null)
	{
		$results = $this->query->lists($column, $key);

		// If the model has a mutator for the requested column, we will spin through
		// the results and mutate the values so that the mutated version of these
		// columns are returned as you would expect from these FlyORM models.
		if ($this->model->hasGetMutator($column))
		{
			foreach ($results as $key => &$value)
			{
				$fill = array($column => $value);

				$value = $this->model->newFromBuilder($fill)->$column;
			}
		}

		return $results;
	}
748395
public function column($column = '*')
    {
        if ('*' == $column) {
            $this->columns = ['*'];
        } else {
            $columns = $this->prepareNames(func_get_args());
            $this->columns = array_merge(
                empty($this->columns) || ['*'] == $this->columns ? [] : $this->columns,
                array_values(array_diff($columns, ['*']))
            );
        }
        return $this;
    }
435408
public function queryValues(string $sql, string $key): array
    {
        $result = [];
        $statement = $this->query($sql);
        while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
            $result[] = $row[$key];
        }

        return $result;
    }
1042724
public function generateColumnOptions(Column $column)
    {
        $options = [];

        $keys = ['length', 'default', 'collation', 'null', 'precision', 'scale', 'after', 'update', 'comment'];
        foreach ($keys as $key) {
            $method = "get{$key}";
            if ($key === 'length') $method = 'getLimit';

            $value = $column->$method();

            if ($key === 'collation') {
                if ($value === null) {
                    $key = 'charset';
                    $value = $column->getCharset();
                }
            }
            if ($value === null) continue;
            if ($key === 'null' && $value === false) continue;

            $options[$key] = $value;
        }
        
        $code = $this->valuetize($options);
        return $code === '[]' ? '' : ', ' . $code;
    }
925851
public function getValue(string $key, string $table)
    {
        $this->checkTable($table);

        $value = $this->$table->get($key);

        return $value ? json_decode($value['value'], true) : [];
    }
516713
public function getEnumValues(string $table, string $column): array {
		$query = <<<QUERY
			SELECT COLUMN_TYPE
			FROM INFORMATION_SCHEMA.COLUMNS
			WHERE TABLE_SCHEMA = :database
			AND TABLE_NAME = :table
			AND COLUMN_NAME = :column
			AND DATA_TYPE IN ('enum','set')
QUERY;
		
		$params = [
			"database" => $this->database,
			"table"    => $table,
			"column"   => $column,
		];
		
		try {
			$type = $this->getVar($query, $params);
		} catch (DatabaseException $databaseException) {
			throw $this->prepareMysqlException($databaseException, $query, $params);
		}
		
		// now we want to (a) confirm that this is an enum (or set) field, and
		// if so (b) extract the set of possible values that it represents.
		// string manipulation to the rescue!
		
		if (strpos($type, "enum(") === 0 || strpos($type, "set(") === 0) {
			
			// the type information is in the form of enum('a','b','c',...,'z').
			// we can match that information with a regular expression as follows.
			
			preg_match_all("/'([^']+)'/", $type, $matches);
			$values = $matches[1];
		} else {
			throw new MysqlException("getEnumValues failed: type mismatch");
		}
		
		return $values;
	}
472271
public function pluck($column, $key = null)
    {
        $results = $this->get(is_null($key) ? [$column] : [$column, $key]);
        // If the columns are qualified with a table or have an alias, we cannot use
        // those directly in the "pluck" operations since the results from the DB
        // are only keyed by the column itself. We'll strip the table out here.
        return array_pluck($results, $this->stripTableForPluck($column), $this->stripTableForPluck($key));
    }
705028
public function pluck($column, $key = null)
    {
        $results = $this->toBase()->pluck($column, $key);

        // If the model has a mutator for the requested column, we will spin through
        // the results and mutate the values so that the mutated version of these
        // columns are returned as you would expect from these Eloquent models.
        if (! $this->model->hasGetMutator($column) &&
            ! $this->model->hasCast($column) &&
            ! in_array($column, $this->model->getDates())) {
            return $results;
        }

        $keys = array_keys($results);
        $results = array_map(
            function ($value) use ($column) {
                return $this->model->newFromBuilder([$column => $value])->$column;
            },
            $results,
            $keys
        );
        return $results;
    }
660754
public function where($column, $value = null)
    {
        // If the column is an array, we will assume it is an array of key-value pairs
        // and can add them each as a where clause.
        if (is_array($column)) {
            return $this->whereNested(function ($query) use ($column) {
                foreach ($column as $key => $value) {
                    $query->where($key, $value);
                }
            });
        }

        $this->wheres[] = compact('column', 'value');

        return $this;
    }