当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::toArray方法代码示例

本文整理汇总了PHP中Collection::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::toArray方法的具体用法?PHP Collection::toArray怎么用?PHP Collection::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collection的用法示例。


在下文中一共展示了Collection::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMap

 public function testMap()
 {
     $this->collection->map(function ($item) {
         return sprintf('%s %s', $item['first_name'], $item['last_name']);
     });
     $this->assertEquals(['john smith', 'kara trace', 'phil mcKay', 'rose smith'], $this->collection->toArray());
 }
开发者ID:dtkahl,项目名称:php-array-tools,代码行数:7,代码来源:CollectionTest.php

示例2: getIncompleteProductLoads

 public function getIncompleteProductLoads($user_id)
 {
     //get user and in progress product requests / ideas
     $user = $this->eloquent->with(['ideas' => function ($query) {
         $query->where('is_fulfilled', '=', 0);
     }])->with(['productRequests' => function ($query) {
         $query->whereNull('product_id');
     }])->find($user_id);
     if (empty($user)) {
         return [];
     }
     $user = $user->toArray();
     $product_requests = $user['product_requests'];
     $ideas = $user['ideas'];
     //compile inprogress items
     $inprogress_items = new \Collection();
     foreach ($product_requests as $product_request) {
         $inprogress_items->add(['type' => 'id load', 'human_time_diff' => \Carbon::createFromFormat('Y-m-d H:i:s', $product_request['created_at'])->diffForHumans(), 'created_at' => $product_request['created_at'], 'updated_at' => $product_request['updated_at'], 'id' => $product_request['id'], 'description' => $product_request['vendor'] . ' ' . $product_request['vendor_id'], 'query' => ['vendor' => $product_request['vendor'], 'vendor_id' => $product_request['vendor_id']]]);
     }
     foreach ($ideas as $idea) {
         $inprogress_items->add(['type' => 'idea load', 'human_time_diff' => \Carbon::createFromFormat('Y-m-d H:i:s', $idea['created_at'])->diffForHumans(), 'created_at' => $idea['created_at'], 'updated_at' => $idea['updated_at'], 'id' => $idea['id'], 'description' => $idea['description'], 'query' => ['idea_description' => $idea['description']]]);
     }
     $inprogress_items->sortBy('created_at');
     return $inprogress_items->toArray();
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:25,代码来源:EloquentUserRepository.php

示例3: fromCollection

 public static function fromCollection(Collection $initialData)
 {
     $tree = new self();
     foreach ($initialData->toArray() as $element) {
         $tree->insert($element);
     }
     return $tree;
 }
开发者ID:nathanklick,项目名称:collections,代码行数:8,代码来源:NaryTree.php

示例4: toArray

 /**
  * Provide a lossless cachable/storable array of the configuration of the
  * ticket and it's timeline
  *
  * @return array
  */
 public function toArray()
 {
     // We want to flatten certain values for quicker searching from store
     $participants = array_map(function ($item) {
         return $item->toArray();
     }, $this->getParticipants());
     $roles = [];
     foreach ($this->getRoles() as $key => $role) {
         $roles[$key] = array_map(function ($item) {
             return $item->toArray();
         }, array_values($role));
     }
     return ['id' => $this->id, 'status' => (string) $this->getStatus(), 'channel' => (string) $this->getChannel(), 'assigned_to' => (string) $this->getAssignedTo(), 'participants' => $participants, 'roles' => $roles, 'tags' => $this->getTags(), 'timeline' => $this->timeline->toArray()];
 }
开发者ID:consolidate,项目名称:ticket,代码行数:20,代码来源:Ticket.php

示例5: merge

 /**
  * @param array|Collection $data
  * @return $this
  */
 public function merge($data)
 {
     if ($data instanceof Collection) {
         $this->_data = array_merge($this->_data, $data->toArray());
     } else {
         $this->_data = array_merge($this->_data, array_values($data));
     }
     $this->_clearIndexes();
     return $this;
 }
开发者ID:dtkahl,项目名称:php-array-tools,代码行数:14,代码来源:Collection.php

示例6: getAllBundles

 /**
  * @return array
  */
 public function getAllBundles()
 {
     return array_merge($this->bundles->toArray(), $this->contributionBundles->toArray());
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:7,代码来源:Developer.php

示例7: getResponses

 public function getResponses()
 {
     return $this->responses->toArray();
 }
开发者ID:trialog,项目名称:p4s-api-bundle,代码行数:4,代码来源:EvaluationModelItem.php

示例8: merge

 /**
  * Adds elements from another collection
  *
  * @param Collection $col
  */
 public function merge(Collection $col)
 {
     $this->elements = array_merge($this->elements, $col->toArray());
 }
开发者ID:ezpn,项目名称:FriendlyXml,代码行数:9,代码来源:Collection.php

示例9: getCategories

 public function getCategories()
 {
     return $this->categories->toArray();
 }
开发者ID:trialog,项目名称:p4s-api-bundle,代码行数:4,代码来源:EvaluationModel.php

示例10: PagerHelper

$collection->add('sixteen', 'diez y seis');
$collection->add('seventeen', 'diez y siete');
$collection->add('eighteen', 'diez y ocho');
$collection->add('ninetten', 'diez y nueve');
$collection->add('twenty', 'viente');
$collection->add('twenty one', 'viente uno');
$collection->add('twenty two', 'viente dos');
$collection->add('twenty three', 'viente tres');
$collection->add('twenty four', 'viente cuatro');
$collection->add('twenty five', 'viente cinco');
$collection->add('twenty six', 'viente seis');
$collection->add('twenty seven', 'viente siete');
$collection->add('twenty eight', 'viente ocho');
$collection->add('twenty nine', 'viente nueve');
$collection->add('thirty', 'treinte');
$datasource = new A_Pager_Array($collection->toArray());
// temporary hack until pager supports Collections
$pager = new A_Pager($datasource);
$pager->setPageSize(3);
// create a request processor to set pager from GET parameters
$request = new A_Pager_Request($pager);
$request->process();
$template = new A_Template_Include('templates/standard_pagination.tpl');
// create a HTML writer to output
#$helper = new A_Pager_HTMLWriter($pager);
// get rows of data
$start_row = $pager->getStartRow();
$end_row = $pager->getEndRow();
$rows = $datasource->getRows($start_row, $end_row);
$helper = new PagerHelper($pager, $template, 2);
?>
开发者ID:TheProjecter,项目名称:skeleton,代码行数:31,代码来源:current_pager_example.php

示例11: testToArray

 public function testToArray()
 {
     $this->assertCount(4, $this->collection->toArray());
 }
开发者ID:dtkahl,项目名称:php-collection,代码行数:4,代码来源:CollectionTest.php

示例12: toArray

 public function toArray()
 {
     $data = parent::toArray();
     if (isset($this->id)) {
         $data['id'] = $this->id;
     }
     return $data;
 }
开发者ID:atomicjets,项目名称:PHP-Rexster,代码行数:8,代码来源:Object.php

示例13: retainAll

 /**
  * @param Collection $elements
  * @return boolean
  */
 public function retainAll(Collection $elements)
 {
     $intersection = array_intersect($this->elements, (array) $elements->toArray());
     $newElements = array_values($intersection);
     $result = $newElements != $this->elements;
     $this->elements = $newElements;
     return $result;
 }
开发者ID:EightArmCode,项目名称:librarian,代码行数:12,代码来源:BasicCollection.php

示例14: fromCollection

 /**
  * Creates new collection using data from another collection
  * 
  * @param \tjsd\collections\Collection $initialData collection providing data to be used
  * @return \self collection filled with given data
  */
 public static function fromCollection(Collection $initialData)
 {
     return new static($initialData->toArray());
 }
开发者ID:nathanklick,项目名称:collections,代码行数:10,代码来源:ArrayCollection.php

示例15: toArray

 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $this->initialize();
     return $this->coll->toArray();
 }
开发者ID:richardmiller,项目名称:mongodb-odm,代码行数:8,代码来源:PersistentCollection.php


注:本文中的Collection::toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。