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


PHP Collection::sortByDesc方法代码示例

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


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

示例1: getCategories

 /**
  * @return Collection
  */
 public function getCategories()
 {
     $set = $this->categories->sortByDesc(function (CategoryModel $category) {
         return $category->spent;
     });
     return $set;
 }
开发者ID:ebbz,项目名称:firefly-iii,代码行数:10,代码来源:Category.php

示例2: getIncomes

 /**
  * @return Collection
  */
 public function getIncomes()
 {
     $set = $this->incomes->sortByDesc(function (stdClass $object) {
         return $object->amount;
     });
     return $set;
 }
开发者ID:RonaldvanMeer,项目名称:firefly-iii,代码行数:10,代码来源:Income.php

示例3: orderBy

 /**
  * Adds a OrderBy to the query
  *
  * @param  string
  * @param  string
  * @return $this
  */
 public function orderBy($column, $direction = 'asc')
 {
     if ($column != null) {
         if ($direction === 'asc') {
             $this->collection = $this->collection->sortBy($column);
         } elseif ($direction === 'desc') {
             $this->collection = $this->collection->sortByDesc($column);
         }
     }
     return $this;
 }
开发者ID:lykegenes,项目名称:laravel-api-response,代码行数:18,代码来源:EloquentCollectionStrategy.php

示例4: invoices

 /**
  * Get a collection of the entity's invoices.
  *
  * @param bool  $includePending
  * @param array $parameters
  *
  * @return \Illuminate\Support\Collection
  */
 public function invoices($includePending = false, $parameters = [])
 {
     $invoices = new Collection();
     $customer = $this->asBraintreeCustomer();
     $parameters = array_merge([TransactionSearch::customerId()->is($customer->id)], $parameters);
     $braintreeTransactions = Transaction::search($parameters);
     $subscriptionIds = [];
     foreach ($braintreeTransactions as $braintreeTransaction) {
         $subscriptionIds[] = $braintreeTransaction->subscriptionId;
     }
     $braintreeSubscriptions = BraintreeSubscription::fetch([], array_unique($subscriptionIds));
     // Here we will loop through the Braintree invoices and create our own custom Invoice
     // instances that have more helper methods and are generally more convenient to
     // work with than the plain Braintree objects are. Then, we'll return the array.
     if (!is_null($braintreeSubscriptions)) {
         foreach ($braintreeSubscriptions as $subscription) {
             if ($subscription->status == BraintreeSubscription::ACTIVE || $includePending) {
                 foreach ($subscription->transactions as $transaction) {
                     $invoices->push(new Invoice($this, $subscription, $transaction));
                 }
             }
         }
     }
     return $invoices->sortByDesc(function ($invoice) {
         return $invoice->date();
     });
 }
开发者ID:LimeDeck,项目名称:cashier-braintree,代码行数:35,代码来源:Billable.php


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