Skip to content

Commit

Permalink
Merge pull request #6 from paulovnas/main
Browse files Browse the repository at this point in the history
Add: Support for allowed sorts
  • Loading branch information
rupadana authored Oct 7, 2023
2 parents ece00d1 + dfc623d commit 560ffff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ You can specified `allowedFilters` and `allowedFields` in your model
Example
```php
class User extends Model {
public static array $allowedFilters = [
public static array $allowedFields = [
'name'
];

public static array $allowedFields = [

public static array $allowedSorts = [
'name',
'created_at'
];

public static array $allowedFilters = [
'name'
];
}
Expand Down
1 change: 1 addition & 0 deletions stubs/PaginationHandler.stub
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PaginationHandler extends Handlers {

$query = QueryBuilder::for($model)
->allowedFields($model::$allowedFields ?? [])
->allowedSorts($model::$allowedSorts ?? [])
->allowedFilters($model::$allowedFilters ?? [])
->paginate(request()->query('per_page'))
->appends(request()->query());
Expand Down

0 comments on commit 560ffff

Please sign in to comment.