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


PHP Collection::reverse方法代码示例

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


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

示例1: doInternalOrder

 private function doInternalOrder()
 {
     if (is_null($this->orderColumn)) {
         return;
     }
     $column = $this->orderColumn[0];
     $stripOrder = $this->options['stripOrder'];
     $self = $this;
     $this->workingCollection = $this->workingCollection->sortBy(function ($row) use($column, $stripOrder, $self) {
         if ($self->getAliasMapping()) {
             $column = $self->getNameByIndex($column);
         }
         if ($stripOrder) {
             if (is_callable($stripOrder)) {
                 return $stripOrder($row, $column);
             } else {
                 return strip_tags($row[$column]);
             }
         } else {
             return $row[$column];
         }
     }, SORT_NATURAL);
     if ($this->orderDirection == BaseEngine::ORDER_DESC) {
         $this->workingCollection = $this->workingCollection->reverse();
     }
 }
开发者ID:MehmetNuri,项目名称:faveo-helpdesk,代码行数:26,代码来源:CollectionEngine.php

示例2: doOrdering

 /**
  * @inheritdoc
  */
 public function doOrdering()
 {
     if (array_key_exists('order', $this->input) && count($this->input['order']) > 0) {
         for ($i = 0, $c = count($this->input['order']); $i < $c; $i++) {
             $order_col = (int) $this->input['order'][$i]['column'];
             $order_dir = $this->input['order'][$i]['dir'];
             if (!$this->isColumnOrderable($this->input['columns'][$order_col])) {
                 continue;
             }
             $column = $this->getOrderColumnName($order_col);
             $this->collection = $this->collection->sortBy(function ($row) use($column) {
                 return $row[$column];
             });
             if ($order_dir == 'desc') {
                 $this->collection = $this->collection->reverse();
             }
         }
     }
 }
开发者ID:Kirylka,项目名称:Scaffold,代码行数:22,代码来源:CollectionEngine.php

示例3: ordering

 /**
  * @inheritdoc
  */
 public function ordering()
 {
     foreach ($this->request->orderableColumns() as $orderable) {
         $column = $this->getColumnName($orderable['column']);
         $this->collection = $this->collection->sortBy(function ($row) use($column) {
             return $row[$column];
         });
         if ($orderable['direction'] == 'desc') {
             $this->collection = $this->collection->reverse();
         }
     }
 }
开发者ID:rayhan0421,项目名称:laravel-datatables,代码行数:15,代码来源:CollectionEngine.php

示例4: ordering

 /**
  * @inheritdoc
  */
 public function ordering()
 {
     foreach ($this->request->orderableColumns() as $orderable) {
         $column = $this->getColumnName($orderable['column']);
         $this->collection = $this->collection->sortBy(function ($row) use($column) {
             $row = Helper::castToArray($row);
             return Arr::get($row, $column);
         });
         if ($orderable['direction'] == 'desc') {
             $this->collection = $this->collection->reverse();
         }
     }
 }
开发者ID:nmardones,项目名称:laravel-datatables,代码行数:16,代码来源:CollectionEngine.php

示例5: ordering

 /**
  * @inheritdoc
  */
 public function ordering()
 {
     if ($this->orderCallback) {
         call_user_func($this->orderCallback, $this);
         return;
     }
     foreach ($this->request->orderableColumns() as $orderable) {
         $column = $this->getColumnName($orderable['column']);
         $this->collection = $this->collection->sortBy(function ($row) use($column) {
             $data = $this->serialize($row);
             return Arr::get($data, $column);
         });
         if ($orderable['direction'] == 'desc') {
             $this->collection = $this->collection->reverse();
         }
     }
 }
开发者ID:marcha,项目名称:laravel-datatables,代码行数:20,代码来源:CollectionEngine.php

示例6: setTweets

 private function setTweets(array $tweets)
 {
     if (null === $tweets) {
         throw new BirderException("Connection error", 1);
     }
     $filteredTweets = array();
     foreach ($tweets as $tweet) {
         $rtTweet = doComparison($tweet->retweet_count, $this->conditions['retweets']['operator'], $this->conditions['retweets']['value']);
         $favTweet = doComparison($tweet->favorite_count, $this->conditions['favorites']['operator'], $this->conditions['favorites']['value']);
         $condition = $this->conditions['condition'] == 'or' ? $rtTweet or $favTweet : ($rtTweet and $favTweet);
         if ($condition) {
             $filteredTweets[] = $tweet;
         }
     }
     $tweets = new Collection($filteredTweets);
     $this->tweets = $tweets->reverse();
 }
开发者ID:thatzad,项目名称:birder,代码行数:17,代码来源:Birder.php

示例7: testReverse

 public function testReverse()
 {
     $data = new Collection(['zaeed', 'alan']);
     $reversed = $data->reverse();
     $this->assertSame([1 => 'alan', 0 => 'zaeed'], $reversed->all());
     $data = new Collection(['name' => 'taylor', 'framework' => 'laravel']);
     $reversed = $data->reverse();
     $this->assertSame(['framework' => 'laravel', 'name' => 'taylor'], $reversed->all());
 }
开发者ID:sa7bi,项目名称:euro16,代码行数:9,代码来源:SupportCollectionTest.php

示例8: middlewares

 /**
  * Return middlewares
  * 
  * @param bool $reverse order
  * 
  * @return Illuminate\Support\Collection
  */
 public function middlewares($reverse = false)
 {
     return $reverse ? $this->_middlewares->reverse() : $this->_middlewares;
 }
开发者ID:irto,项目名称:oauth2-proxy,代码行数:11,代码来源:Server.php


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