本文整理汇总了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;
}
示例2: getIncomes
/**
* @return Collection
*/
public function getIncomes()
{
$set = $this->incomes->sortByDesc(function (stdClass $object) {
return $object->amount;
});
return $set;
}
示例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;
}
示例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();
});
}