liqrgv/query-filter-laravel

Query filter shortcut for controller

1.0.1 2020-07-10 03:22 UTC

This package is auto-updated.

Last update: 2024-04-29 04:26:57 UTC


README

Build Status codecov

Change your Request into Query builder

With this package, we can prevent doing tedious work of composing query builder This package will turn URL query

book?filter[title][is]=Harry&filter[published_at][>]=2010-10-13

into

Book::query()
  ->where('title', '=', 'Harry')
  ->where('published_at', '>', '2010-10-13')

Getting Started

You can install this package via composer CLI using

composer require liqrgv/query-filter-laravel

Usage

You can add RequestParser class to your route closure

Route::get('/model', function(RequestParser $parser) {
    $builder = $parser->getBuilder();
    // do something with builder
    .............
});

or on your controller

public function index(RequestParser $parser) {
    $builder = $parser->getBuilder();
    // do something with builder
    .............
}

Running the tests

In order to running the test, you should have composer on your system. Read more on https://getcomposer.org/doc/00-intro.md

You should install dependency for testing with

composer install

After that, you can run all test with

./phpunit

Deployment

(TBD)

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Septian Hari - Initial work - LIQRGV

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache License

Acknowledgments

  • Hat tip to anyone whose code was used
  • Inspiration
  • etc