Download the PHP package kemodev/laravel-restful-filter without Composer
On this page you can find all versions of the php package kemodev/laravel-restful-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-restful-filter
Laravel RESTful Filter
A simple way to filter your query on RESTful API
Compatibility
| Framework | Version |
|---|---|
| Laravel | 5.*, 6.*, 7.*, 8.* |
| Lumen | 5.*, 6.*, 7.*, 8.* |
Limitation
- Currently, only working on SQL type Database (already tested on MySQL, PostgreSQL, SQL Server)
- Probably SQL query not optimized (already checked on this but i think it doesn't have, the result was fast. In the end, it's your choise)
- Sorting through relation not available
- Filter
BetweenandInnot available - Can't add custom logic
Available Search Operators
- Less Than
- Less Than Equal
- Greater Than
- Greater Than Equal
- Equal
- LIKE
- NOT
Installation
Install from composer
Use Package on your Model
Get Started
First, you need to define what field that able to filter with your API
1. Filter
There are 3 kind available method for filter:
-
Basic
-
Relation
- All of Kind
This method usually used when using one field filter like on default datatables
2. Sorting
If you notice, that variables was associate array with key indicate the query param on URL and value was the column name.
3. Usage
The most basic one, you can use like these
with this code, it will assume that you produce url like
https://[email protected]&sort=name_asc
But the $filter variables take scope to wide, because you may have another query params that not related for filter your data. The best practice that i assume was write your code like these
with this code, it will assume that you produce url like
https://your-domain.dev?filters[name]=febryan&filters[email][email protected]&sort=name_asc&signature=123qweasdzxc
For using available search operator on filter, you can input your query params like these:
- Less Than:
filters[age]=lt:12 - Less Than Equal:
filters[age]=lte:12 - Greater Than:
filters[age]=gt:12 - Greater Than Equal:
filters[age]=gte:12 - Equal:
filters[name]=John Doe - LIKE:
filters[name]=like:john - NOT:
filters[name]=not:John Doe
For change direction on sorting, you can input your query params like these:
- Ascending:
sort=name_asc - Descending:
sort=name_desc
Or you want declare multiple sorting, just type your query params like these:
sort=name_asc,email_desc
Contributing
Any contributions welcome! but if you are busy to contribute or you don't know how to contribute because seeing my ugly code, you can do thing on below to declare your contributions.
Stars the project
If you find this package useful and you want to encourage me to maintain and work on it, Just press the star button to declare your willing.
Reward me with a cup of tea 🍵
Send me as much as a cup of tea worth in your country, so I'll have the energy to maintain this package.
Ethereum: 0x8a43C741519ff8447c033E9D0a49F94A6EB76047