當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Collection::lists方法代碼示例

本文整理匯總了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);
 }
開發者ID:philtweir,項目名稱:glossia-scratch-test-site,代碼行數:31,代碼來源:SimulationController.php

示例2: buildContent

 /**
  * @param Collection $posts
  * @return array
  */
 protected static function buildContent(Collection $posts)
 {
     return implode(', ', $posts->lists('id')->toArray());
 }
開發者ID:flagrow,項目名稱:flarum-ext-split,代碼行數:8,代碼來源:DiscussionSplitPost.php

示例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();
 }
開發者ID:laraviet,項目名稱:catalog,代碼行數:11,代碼來源:Category.php

示例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();
 }
開發者ID:breadam,項目名稱:emberize,代碼行數:14,代碼來源:Emberize.php


注:本文中的Illuminate\Database\Eloquent\Collection::lists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。