https://github.com/railken/lara-eye
Filter your Query\Builder using a structured query language
https://github.com/railken/lara-eye
api composer eloquent filter laravel library php query search
Last synced: 13 days ago
JSON representation
Filter your Query\Builder using a structured query language
- Host: GitHub
- URL: https://github.com/railken/lara-eye
- Owner: railken
- License: mit
- Created: 2018-04-27T12:31:11.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-04T22:39:20.000Z (about 1 year ago)
- Last Synced: 2024-07-23T09:58:45.634Z (9 months ago)
- Topics: api, composer, eloquent, filter, laravel, library, php, query, search
- Language: PHP
- Homepage:
- Size: 135 KB
- Stars: 38
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Eye
[](https://github.com/railken/lara-eye/actions)
Filter your ```Illuminate\DataBase\Query\Builder``` using a structured query language.
This can be pretty usefull when you're building an API and you don't want to waste hours of your time creating predefined filters that may change at any time.## Requirements
PHP 8.1 or later.
## Usage
```php
use Railken\LaraEye\Filter;
use Railken\SQ\Exceptions\QuerySyntaxException;
use App\Foo;// Instance of Illuminate\DataBase\Query\Builder
$query = (new Foo())->newQuery()->getQuery();$str_filter = "x > 5 or y < z";
$filter = new Filter("foo", ['id', 'x', 'y', 'z', 'created_at', 'updated_at']);
try {
$filter->build($query, $str_filter);
} catch (QuerySyntaxException $e) {
// handle syntax error
}```
Syntax [here](https://github.com/railken/search-query)
## Composer
You can install it via [Composer](https://getcomposer.org/) by typing the following command:
```bash
composer require railken/lara-eye
```## Demo

## License
Open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).