本文整理匯總了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);
}