本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::lists方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::lists方法的具体用法?PHP Builder::lists怎么用?PHP Builder::lists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::lists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lists
/**
* @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();
}
示例2: lists
/**
* 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();
}
示例3: lists
/**
* 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;
}
示例4: valuesFrom
/**
* 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;
}
示例5: lists
/**
* 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);
}
示例6: getList
/**
* @param string|int $value
* @param string $key
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getList($value, $key = 'id')
{
return $this->model->lists($value, $key);
}