Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stephenlake/laravel-queryable
Filter models by their attributes and/or relations via HTTP URI query params.
https://github.com/stephenlake/laravel-queryable
Last synced: 3 months ago
JSON representation
Filter models by their attributes and/or relations via HTTP URI query params.
- Host: GitHub
- URL: https://github.com/stephenlake/laravel-queryable
- Owner: stephenlake
- License: mit
- Archived: true
- Created: 2018-09-16T22:46:09.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-09T18:37:01.000Z (almost 5 years ago)
- Last Synced: 2024-04-04T19:32:53.702Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 132 KB
- Stars: 46
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Queryable
![tests](https://img.shields.io/travis/stephenlake/laravel-queryable/master.svg?style=flat-square)
![styleci](https://github.styleci.io/repos/149042065/shield?branch=master&style=flat-square)
![scrutinzer](https://img.shields.io/scrutinizer/g/stephenlake/laravel-queryable.svg?style=flat-square)
![downloads](https://img.shields.io/packagist/dt/stephenlake/laravel-queryable.svg?style=flat-square)
![release](https://img.shields.io/github/release/stephenlake/laravel-queryable.svg?style=flat-square)
![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)**Laravel Queryable** is a light weight package containing simple injectable model traits with configurable attributes to perform powerful and flexible queries of your models dynamically from static HTTP routes.
Made with ❤️ by [Stephen Lake](http://stephenlake.github.io/)
## No Longer Maintained :exclamation:
This package is no longer maintained as a far more flexible package exists, it is highly recommended to use [Spatie's Laravel Query Builder](https://docs.spatie.be/laravel-query-builder/v2/introduction/) instead. If you would like to take over this package as maintainer, please get in touch with me.## Getting Started
Install the package via composer.
composer require stephenlake/laravel-queryable
Add the trait to your model:use \Queryable\Traits\QueryParamFilterable;
Define filters on your model:
YourModel::withFilters(['name', 'content', 'created_at'])->get();
Then add dynamic queryables to your HTTP routes:
https://www.example.org?name=Awesome&content=*awesome*&created_at>=2018
This automatically adds the following to the query builder:
YourModel::where('name', 'Awesome')
->where('content', 'like', '%awesome%')
->where('created_at, '>=', '2018')
#### See [documentation](https://stephenlake.github.io/laravel-queryable/) for the full list of available operators and further usage.## License
This library is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.