Eloquent sortBy - Angabe asc oder desc
Versucht Sortieren meine eloquente Sammlung:
$collection->sortBy('field');
Gibt es keine Informationen in Laravel 4 docs auf wie wählen Sie absteigend oder aufsteigend für diese Art Methode.
Ist es möglich?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Laravel 5
https://laravel.com/docs/5.8/collections#method-sortby
Laravel 4
https://laravel.com/api/4.2/Illuminate/Database/Eloquent/Collection.html#method_sortBy
Nutzung
Sortieren von ASC: Laravel Docs - sortBy()
$collection->sortBy('field');
Sortieren von DESC: Laravel Docs - sortByDesc()
$collection->sortByDesc('field');
In 4.2, der zweite parameter muss ein int, SORT_REGULAR ist Standard
https://laravel.com/api/4.2/Illuminate/Database/Eloquent/Collection.html#method_sortBy
$collection->sortBy('Feld', SORT_REGULAR, true); //true für absteigend