Download the PHP package makeabledk/laravel-querykit without Composer
On this page you can find all versions of the php package makeabledk/laravel-querykit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-querykit
Laravel Query Kit
This package provides a handy way to query eloquent-scopes on model instances in Laravel.
Traditionally you may find yourself having a scopeAccepted
and then additionally a ìsAccepted
helper method on your model.
Well, Bon Voyage code-duplication. QueryKit is here to the rescue! 🔥
--
Makeable is web- and mobile app agency located in Aarhus, Denmark.
Installation
You can install this package via composer:
For Laravel version prior 5.5: Add the service provider to your config/app.php:
Usage
Whenever you have a query scope on an Eloquent Model, you can apply the following trait to add QueryKit:
Out of the box Laravel offers us a convenient way to query against our database:
But with query-kit you are now also able to check if a model instance passes a given scope:
Pretty cool, right?
Much more advanced functionality is supported than this simple example.
See Currently supported methods further down.
Provided methods on QueryKit
passesScope
failsScope
Currently supported methods
As of this moment QueryKit supports the following query methods
- orWhere
- orWhereIn
- orWhereBetween
- orWhereDate
- orWhereDay
- orWhereMonth
- orWhereNotBetween
- orWhereNotIn
- orWhereNotNull
- orWhereNull
- orWhereTime
- orWhereYear
- where
- whereIn
- whereBetween
- whereDate
- whereDay
- whereMonth
- whereNotBetween
- whereNotIn
- whereNotNull
- whereNull
- whereTime
- whereYear
- whereColumn
QueryKit tries to support most of the argument types that Eloquent Builder supports, but there might exceptions.
Also, do note that advanced joins and relations queries won't work.
Extending QueryKit
Say that you want to add functionality for Laravel QueryBuilder's 'whereBetween' method:
Create a WhereBetween that implements \Makeable\QueryKit\Contracts\QueryConstraint.
Next register the constraint in your AppServiceProvider's register method:
You can also use the above method to override the existing implementations.
Related packages
Make sure to checkout our makeabledk/laravel-eloquent-status package that streamlines the way you handle model-state across your application.
Testing
You can run the tests with:
Contributing
We are happy to receive pull requests for additional functionality. Please see CONTRIBUTING for details.
Credits
- Rasmus Christoffer Nielsen
- All Contributors
License
Attribution-ShareAlike 4.0 International. Please see License File for more information.