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