From 5d2c2770133006732a41e703553e17fe9855595f Mon Sep 17 00:00:00 2001 From: William Martins Date: Mon, 22 Nov 2021 12:18:31 -0300 Subject: [PATCH] New sample with multiple default sorts --- docs/features/sorting.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/features/sorting.md b/docs/features/sorting.md index 9c2cf0f8..7c542d5c 100644 --- a/docs/features/sorting.md +++ b/docs/features/sorting.md @@ -45,6 +45,18 @@ $users = QueryBuilder::for(User::class) // Will retrieve the users sorted descendingly by name ``` +You can define multiple default sorts + +```php +// GET /users +$users = QueryBuilder::for(User::class) + ->defaultSort('-street', 'name') + ->allowedSorts('name', 'street') + ->get(); + +// Will retrieve the users sorted descendingly by street than in ascending order by name +``` + You can sort by multiple properties by separating them with a comma: ```php