本文整理汇总了PHP中Illuminate\Database\Eloquent\Collection::lists方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::lists方法的具体用法?PHP Collection::lists怎么用?PHP Collection::lists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Collection
的用法示例。
在下文中一共展示了Collection::lists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restore
public function restore()
{
if (!Input::has('batch')) {
return Response::json(['message' => 'Need guid and batch'], 400);
}
$batch = preg_replace('/[^0-9-_]+/', '', Input::get('batch'));
if (Input::has('guid')) {
$guids = [preg_replace('/[^A-Z0-9-]+/', '', Input::get('guid'))];
} else {
$guids = array_map(function ($x) {
return preg_replace('/[^A-Z0-9-]+/', '', $x);
}, array_filter(scandir(public_path() . '/backups/' . $batch), function ($x) {
return $x[0] != '.';
}));
}
$simulations = new Collection();
foreach ($guids as $id) {
$path = public_path() . '/backups/' . $batch . '/' . $id . '.xml';
if (!file_exists($path)) {
return Response::json(['message' => 'Cannot find backup', 'guid' => $id, 'batch' => $batch, 'path' => $path], 400);
}
$xml = new DOMDocument();
$xml->load($path);
try {
$simulations[] = Simulation::fromXml($xml);
} catch (Exception $e) {
return Response::json($e, 400);
}
}
return Response::json($simulations->lists('Id'), 200);
}
示例2: buildContent
/**
* @param Collection $posts
* @return array
*/
protected static function buildContent(Collection $posts)
{
return implode(', ', $posts->lists('id')->toArray());
}
示例3: getAllEndChildrenCategory
public static function getAllEndChildrenCategory()
{
$allCategories = static::getAllCategories();
$endChildrenCategory = new EloquentCollection();
foreach ($allCategories as $category) {
if ($category->isEndChild()) {
$endChildrenCategory->push($category);
}
}
return $endChildrenCategory->lists('title', 'id')->all();
}
示例4: getCollectionIdentifierValues
private function getCollectionIdentifierValues($resourceName, Collection $collection)
{
if (isset($this->configIdentifiers[$resourceName])) {
$identifier = $this->configIdentifiers[$resourceName];
if (isset($identifier["value"])) {
return $collection->lists($identifier["value"]);
}
}
if (isset($this->configIdentifier["value"])) {
$key = $this->configIdentifier["value"];
return $collection->lists($key);
}
return $collection->modelKeys();
}