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


PHP Collection::all方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Collection::all方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::all方法的具體用法?PHP Collection::all怎麽用?PHP Collection::all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Collection的用法示例。


在下文中一共展示了Collection::all方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getAllPermissions

 /**
  * @param GrantableInterface $grantable
  *
  * @return array
  */
 public function getAllPermissions(GrantableInterface $grantable)
 {
     if (is_null($this->permissions) || $this->permissions->isEmpty()) {
         $this->initialize($grantable);
     }
     $result = $this->permissions->all();
     array_filter($result, function ($item) {
         return $item;
     });
     return array_keys($result);
 }
開發者ID:ndrx-io,項目名稱:elude,代碼行數:16,代碼來源:Manager.php

示例2: buildSchema

 /**
  * Generate GraphQL Schema.
  *
  * @return \GraphQL\Schema
  */
 public function buildSchema()
 {
     // Initialize types
     $this->types()->each(function ($type, $key) {
         $type = $this->type($key);
         if (method_exists($type, 'getInterfaces') && !empty($type->getInterfaces())) {
             $this->typesWithInterfaces->push($type);
         }
     });
     $queryFields = $this->queries()->merge($this->connections()->toArray());
     $mutationFields = $this->mutations();
     $queryType = $this->generateSchemaType($queryFields, 'Query');
     $mutationType = $this->generateSchemaType($mutationFields, 'Mutation');
     return new Schema(['query' => $queryType, 'mutation' => $mutationType, 'types' => $this->typesWithInterfaces->all()]);
 }
開發者ID:nuwave,項目名稱:lighthouse,代碼行數:20,代碼來源:GraphQL.php

示例3: loadItems

 /**
  * Loads the Eloquent models for the indexed documents found by the search.
  * Uses eager loading for the specified relations array.
  *
  * @param  array|null $with
  * @return \Elodex\Collection
  */
 protected function loadItems(array $with = null)
 {
     $ids = array_keys($this->documents->all());
     $class = $this->entityClass;
     // Eager load the index relations by default.
     if (is_null($with)) {
         $with = (new $class())->getIndexRelations();
     }
     // Load the Eloquent models from the DB.
     $collection = $class::with($with)->find($ids);
     // The database query returns the items in a random order which means
     // a previously specified sort order in the document search will be lost.
     // So we need to manually bring the result in the desired order.
     $dictionary = $collection->getDictionary();
     $sorted = [];
     foreach ($ids as $id) {
         $model = $dictionary[$id];
         // Fill the model with index metadata.
         if (isset($this->metadata[$id]['_score'])) {
             $model->setIndexScore($this->metadata[$id]['_score']);
         }
         if (isset($this->metadata[$id]['_version'])) {
             $model->setIndexVersion($this->metadata[$id]['_version']);
         }
         $sorted[$id] = $model;
     }
     return new Collection($sorted);
 }
開發者ID:elodex,項目名稱:elodex,代碼行數:35,代碼來源:SearchResult.php

示例4: prepareElement

 /**
  * Mutate an XML element based on the given data.
  *
  * @param Collection $data
  * @param SimpleXMLElement $element
  * @param object $object The object.
  * @param mixed $providedKey
  * @return SimpleXMLElement The new element.
  */
 protected function prepareElement(Collection $data, SimpleXMLElement $element, $object, $providedKey = null) : SimpleXMLElement
 {
     foreach ($data->all() as $value) {
         $this->prepareWithReflection($value, $element, $object);
     }
     return $element;
 }
開發者ID:fetchleo,項目名稱:laravel-xml,代碼行數:16,代碼來源:ObjectConverter.php

示例5: testBulkOperationException

 public function testBulkOperationException()
 {
     $bulkItems = new Collection([['id' => 1], ['id' => 2], ['id' => 3], ['id' => 4]]);
     $items = [['create' => ['_index' => 'my_index', '_type' => 'my_type', '_id' => 1, 'status' => 409, 'error' => ['type' => 'document_already_exists_exception', 'reason' => '[my_index][1]: document already exists', 'shard' => '1', 'index' => 'my_index']]], ['update' => ['_index' => 'my_index', '_type' => 'my_type', '_id' => 2, 'status' => 404, 'error' => ['type' => 'document_missing_exception', 'reason' => '[my_index][2]: document missing', 'shard' => '-1', 'index' => 'my_index']]], ['delete' => ['_index' => 'my_index', '_type' => 'my_type', '_id' => 3, 'status' => 404, 'found' => false]], ['index' => ['_index' => 'my_index', '_type' => 'my_type', '_id' => 4, 'status' => 200]]];
     $e = BulkOperationException::createForResults($items, $bulkItems->all());
     $failedItems = $e->getFailedItems();
     $failedIds = Arr::pluck($failedItems, 'id');
     $this->assertEquals([1, 2], $failedIds);
 }
開發者ID:elodex,項目名稱:elodex,代碼行數:9,代碼來源:BulkOperationTest.php

示例6: render

 /**
  * @return string
  */
 public function render()
 {
     $value = $this->choices->all();
     if (!empty($this->label)) {
         $label = Element::create('label', $this->label);
         $this->nest($label, 'label');
         $this->nest('<br>');
     }
     $this->nest($value, 'choices');
     return parent::render();
 }
開發者ID:potterywp,項目名稱:potter,代碼行數:14,代碼來源:Checkable.php

示例7: outputAssets

 /**
  * Output the collection assets
  * @param  \Illuminate\Support\Collection $collection
  * @param  string $type
  * @return string
  */
 public function outputAssets($collection, $type)
 {
     if (!$collection->isEmpty()) {
         $link = $this->determineLinkingAttribute($type);
         $output = array();
         foreach ($collection->all() as $name => $attr) {
             $output[$name] = $this->createAssetTag($type, $link, $attr);
         }
         return implode($output, '');
     }
 }
開發者ID:nathanburkett,項目名稱:ecosystem,代碼行數:17,代碼來源:Ecosystem.php

示例8: buildColumnByCollection

 /**
  * Transform row column by collection.
  *
  * @param array $row
  * @param \Illuminate\Support\Collection $columns
  * @param string $type
  * @return array
  */
 protected function buildColumnByCollection(array $row, Collection $columns, $type = 'printable')
 {
     $results = [];
     foreach ($columns->all() as $column) {
         if ($column[$type]) {
             $data = array_get($row, $column['data']);
             $results[$column['title']] = $type == 'exportable' ? strip_tags($data) : $data;
         }
     }
     return $results;
 }
開發者ID:HeartlandTechie,項目名稱:laravel-datatables,代碼行數:19,代碼來源:DataTransformer.php

示例9: run

 public function run()
 {
     if ($this->rules instanceof Collection) {
         $this->rules = $this->rules->all();
     }
     if (is_string($this->rules) && is_subclass_of($this->rules, BaseInterceptor::class)) {
         $this->rules = app($this->rules)->apply($this->actor, $this->data, $this->obj);
     }
     $validator = app('validator')->make($this->data->all(), $this->rules, $this->messages, $this->labels);
     if ($validator->fails()) {
         abort(400, json_encode($validator->errors()->all()));
     }
     return $validator;
 }
開發者ID:alex-oliveira,項目名稱:ao-scrud,代碼行數:14,代碼來源:ValidateFacade.php

示例10: buildColumnByCollection

 /**
  * Transform row column by collection.
  *
  * @param array $row
  * @param \Illuminate\Support\Collection $columns
  * @param string $type
  * @return array
  */
 protected function buildColumnByCollection(array $row, Collection $columns, $type = 'printable')
 {
     $results = [];
     foreach ($columns->all() as $column) {
         if ($column[$type]) {
             $title = $column['title'];
             $data = array_get($row, $column['data']);
             if ($type == 'exportable') {
                 $data = $this->decodeContent($data);
                 $title = $this->decodeContent($title);
             }
             $results[$title] = $data;
         }
     }
     return $results;
 }
開發者ID:rafaelqm,項目名稱:laravel-datatables,代碼行數:24,代碼來源:DataTransformer.php

示例11: applyTransform

 public function applyTransform()
 {
     $transforms = $this->transforms->all();
     $datas = empty($this->inputDatas) ? [] : $this->inputDatas;
     if (empty($transforms) || empty($datas)) {
         $this->results = $datas;
         return $this;
     }
     $tmp = [];
     foreach ($transforms as $transform) {
         $tmp = Transform::make($transform, $datas);
     }
     $this->hasTransForm = TRUE;
     $this->results = new Collection($tmp);
     return $this;
 }
開發者ID:liubusian,項目名稱:laravel5,代碼行數:16,代碼來源:BaseEntity.php

示例12: go

 /**
  * Go
  *
  * Goes through all of the registered modules and attempts
  * to activate them. Performs checks to ensure that modules
  * that declare dependencies that have not been satisfied
  * will not be activated.
  *
  * Registers any directories with the class loader
  *
  * @return void
  */
 public function go()
 {
     $this->handlePreRegistered();
     $toActivate = $this->registeredModules->all();
     // This 'while' loop runs continuously allowing for modules
     // to be checked multiple times which allows for dependencies.
     while (count($toActivate) > 0) {
         foreach ($toActivate as $name => $module) {
             $canActivate = true;
             $dependencies = $module->dependencies();
             // If we've got dependencies, check them all to make sure all have been activated
             // before activating this particular module.
             if (!empty($dependencies)) {
                 foreach ($dependencies as $dependency) {
                     // First off, if this dependency hasn't even been register, we can never
                     // activate this module, so let's skip it and not try again.
                     if (!$this->registeredModules->has($dependency)) {
                         $canActivate = false;
                         $this->dispatcher->fire(self::EVENT_ACTIVATION_FAILED . ' ' . $name, $module);
                         unset($toActivate[$name]);
                         continue;
                     }
                     // At this point, the dependency has been registered but not activated,
                     // so let's skip this module and come back to it.
                     if (!$this->activeModules->has($dependency)) {
                         $canActivate = false;
                     }
                 }
             }
             // Now let's activate this sucka! Also, we remove it from the list
             // so we don't try to activate it again.
             if ($canActivate) {
                 $this->activeModules->put($name, $module->activate());
                 $this->dispatcher->fire(self::EVENT_ACTIVE . " {$name}", $module);
                 unset($toActivate[$name]);
             }
         }
     }
     $this->classLoader->register();
 }
開發者ID:suitetea,項目名稱:modularlaravel,代碼行數:52,代碼來源:Manager.php

示例13: handleiSortCol_0

 /**
  * @param $value
  */
 protected function handleiSortCol_0($value)
 {
     if (Input::get('sSortDir_0') == 'desc') {
         $direction[$value] = BaseEngine::ORDER_DESC;
     } else {
         $direction[$value] = BaseEngine::ORDER_ASC;
     }
     $columns = array();
     //check if order is allowed
     if (empty($this->orderColumns)) {
         $columns[] = array(0 => $value, 1 => $this->getNameByIndex($value));
         $this->order($columns, $direction);
         return;
     }
     //prepare order array
     $cleanNames = array();
     foreach ($this->orderColumns as $c) {
         if (strpos($c, ':') !== FALSE) {
             $cleanNames[] = substr($c, 0, strpos($c, ':'));
         } else {
             $cleanNames[] = $c;
         }
     }
     $iSortingCols = Input::get('iSortingCols');
     $sortingCols[] = $value;
     for ($i = 1; $i < $iSortingCols; $i++) {
         $isc = Input::get('iSortCol_' . $i);
         $sortingCols[] = $isc;
         $direction[$isc] = Input::get('sSortDir_' . $i);
     }
     $allColumns = array_keys($this->columns->all());
     foreach ($sortingCols as $num) {
         if (isset($allColumns[$num]) && in_array($allColumns[$num], $cleanNames)) {
             $columns[] = array(0 => $num, 1 => $this->orderColumns[array_search($allColumns[$num], $cleanNames)]);
         }
     }
     $this->order($columns, $direction);
     return;
 }
開發者ID:rafwlaz,項目名稱:Datatable,代碼行數:42,代碼來源:BaseEngine.php

示例14: getAllAttributes

 /**
  * @return Collection
  */
 public function getAllAttributes()
 {
     $all = new Collection();
     foreach ($this->attributes as $attr) {
         $all->put($attr->name, $attr);
     }
     foreach ($this->sections->all() as $section) {
         foreach ($section->getAttributes() as $attr) {
             $all->put($attr->name, $attr);
         }
     }
     foreach ($this->tabs->all() as $tab) {
         foreach ($tab->getAttributes() as $attr) {
             $all->put($attr->name, $attr);
         }
         foreach ($tab->getSections() as $section) {
             foreach ($section as $attr) {
                 $all->put($attr->name, $attr);
             }
         }
     }
     return $all;
 }
開發者ID:wearejust,項目名稱:shapeshifter,代碼行數:26,代碼來源:Form.php

示例15: getSheetArrayFromAnyKindOfCollection

 /**
  * Takes any kind of collection returned by Maatwebsite\Excel and turns it
  * into an array of RowCollections.
  *
  * This is needed because the library returns a SheetCollection if there are
  * multiple sheets and a RowCollection if there is only one.
  *
  * @see http://www.maatwebsite.nl/laravel-excel/docs/import#results
  * @param mixed $collection A RowCollection or SheetCollection.
  * @result \Maatwebsite\Excel\Collections\RowCollection[]
  */
 protected function getSheetArrayFromAnyKindOfCollection(Collection $collection)
 {
     if ($collection instanceof RowCollection) {
         $sheets = [$collection];
     } elseif ($collection instanceof SheetCollection) {
         $sheets = $collection->all();
     } else {
         throw new Exception('Unknown class returned from Excel: ' . get_class($collection));
     }
     return $sheets;
 }
開發者ID:npmweb,項目名稱:upload-handler,代碼行數:22,代碼來源:BaseExcelImportUploadHandler.php


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