當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。