Assuming I want to sort a list of users by reputation:
By doing $query->get()->sortByDesc('reputation')
, I receive the following results:
How can I sort the collection to receive results similar to the first example? In other words, if users have 0 reputation, how can I change the sorting method to creation date by descending order?
在查询中链接两个orderBy()
方法:
->orderBy('created_at', 'desc')->orderBy('reputation', 'desc')->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.