Skip to content

Commit

Permalink
added changelog & dingo example
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schobel committed Sep 9, 2016
1 parent 515ce29 commit 1cd3bd1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Change Log

#### 2016-09-09
Initial version
* configuration file
* parameters
* limit
* page
* sort
* named filters

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Uses Dingo/API Request Query Parameters to filter Laravel Models
First, add the respective line to your composer file
```json
"require" : {
...
...,
"johannesschobel/dingoquerymapper": "dev-master"
}
```
Expand Down Expand Up @@ -80,10 +80,25 @@ $users = User::where('is_active', '=', true)
->take(10);
```

## Dingo/API Example
If you use [Dingo/API](https://github.com/dingo/api) as your preferred API framework, you can use this package right
away. If you are not using Dingo/API, you should really consider using it - it is awesome!

However, all of the information described above still remains when using Dingo/API. Only, the returning the results
varies because you need to use Dingo's response objects.

You can simply return your results using
```php
return $this->response
->paginator($users, new UserTransformer());
```

That's all - really!

## Parameters
This plugin provides some pre-defined parameter names to be automatically filled.

### `Limit` and `Page`
### `limit` and `page`
In order to limit the amount of response elements, simply add respective `limit` query parameter, like this:

```php
Expand All @@ -107,7 +122,7 @@ For example
```
sorts the results by age (ascending), then by name (descending; note the `-`before the `name` field!)

### `filter`
### `custom filters`
Of course you may pass custom query parameters to the builder in order to `filter` the requested data.
For example:

Expand Down

0 comments on commit 1cd3bd1

Please sign in to comment.