Skip to content

Commit 51ceea0

Browse files
authoredDec 16, 2024
Merge pull request #62 from Lomkit/GautierDele-patch-1
Update 2.exposed-data.md
2 parents 0ee1ffc + 88a652c commit 51ceea0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

Diff for: ‎content/3.resources/2.exposed-data.md

+24
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ public function fields(\Lomkit\Rest\Http\Requests\RestRequest $request)
3434
}
3535
```
3636

37+
## Sorts
38+
39+
The fields allowed are the one you define in the `fields` method
40+
41+
### Default sort
42+
43+
By default, Rest Api sorts by `id` descending, if you want to change this, extend the `defaultOrderBy` method.
44+
45+
```php
46+
/**
47+
* Return the default ordering for resource queries.
48+
*
49+
* @param RestRequest $request
50+
*
51+
* @return array
52+
*/
53+
public function defaultOrderBy(RestRequest $request): array
54+
{
55+
return [
56+
'id' => 'desc',
57+
];
58+
}
59+
```
60+
3761
## Scopes
3862

3963
Each Rest resource contains a `scopes` method. This method returns an array of strings specifying the scopes you want to expose.

0 commit comments

Comments
 (0)