当前位置: 首页>>代码示例>>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;未经允许,请勿转载。