https://github.com/mcklayin/query-filter
https://github.com/mcklayin/query-filter
laravel queryfilter
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mcklayin/query-filter
- Owner: mcklayin
- License: mit
- Created: 2018-05-23T20:39:28.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-29T16:40:17.000Z (over 6 years ago)
- Last Synced: 2024-04-21T22:56:01.432Z (about 2 years ago)
- Topics: laravel, queryfilter
- Language: PHP
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# QueryFilter
Easily create filters for your Eloquent model.
Based on [Jeffray Way's Laracast tutorial](https://github.com/laracasts/Dedicated-Query-String-Filtering/).
## Installation
The library is currently not available on Composer, so you have to declare it manually in your `composer.json`.
To do this, add the following in your `composer.json` :
```json
{
"require" : {
"mcklayin/query-filter": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mcklayin/query-filter"
}
]
}
```
Or type in console:
composer require "mcklayin/query-filter @dev"
## Usage
- Create your model filters, for exemple in a `App\Http\Filters` namespace :
```php
builder->where('foo', 'bar');
//or
//return $this->where('foo', 'bar');
}
}
```
- Then, add the `FilterableTrait` on your model to allow the use of `MyModel::filter()` :
```php
get();
return response()->json(compact('data'));
}
}
```