/** * @param string $value * @param string $key * @return array */ public function lists($value, $key = null) { $this->applyCriteria(); $this->newQuery()->eagerLoadRelations(); $lists = $this->model->lists($value, $key); if (is_array($lists)) { return $lists; } return $lists->all(); }
/** * Get an array with the values of a given column. * * @param string $value * @param string $key * * @return array */ public function lists($value, $key = null) { $this->newQuery(); $lists = $this->query->lists($value, $key); if (is_array($lists)) { return $lists; } return $lists->all(); }
/** * Get an array with the values of a given column. * * @param $column * @param null $key * @return \Illuminate\Support\Collection */ public function lists($column, $key = null) { // Save the results from the builder $results = $this->builder->lists($column, $key); // Reset the builder, just in case we are going to use this repository more then once $this->newBuilder(); // Return stuff return $results; }
/** * Automatically gets the values from an Eloquent class/query * * @param \Illuminate\Database\Eloquent\Builder|string $query * @param string $key column to use as values * @param null|string $label column to use as value label, if null it will match the value * @return $this */ function valuesFrom($query, $key, $label = null) { if (!$label) { $label = $key; } if ($query instanceof \Illuminate\Database\Eloquent\Builder) { $rs = $query->lists($label, $key); } else { $rs = call_user_func([$query, 'lists'], $label, $key); } $this->values($rs->toArray()); return $this; }
/** * Get an array with the values of a given column. * * @param string $column * @param string|null $key * @return \Illuminate\Support\Collection * @static */ public static function lists($column, $key = null) { return \Illuminate\Database\Eloquent\Builder::lists($column, $key); }
/** * @param string|int $value * @param string $key * * @return \Illuminate\Database\Eloquent\Collection */ public function getList($value, $key = 'id') { return $this->model->lists($value, $key); }