PHPackages                             makeabledk/laravel-querykit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. makeabledk/laravel-querykit

ActiveLibrary[Database &amp; ORM](/categories/database)

makeabledk/laravel-querykit
===========================

v4.3.0(3mo ago)3389.4k↑19.7%61CC-BY-SA-4.0PHPPHP ^8.1CI failing

Since Jun 27Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/makeabledk/laravel-query-kit)[ Packagist](https://packagist.org/packages/makeabledk/laravel-querykit)[ RSS](/packages/makeabledk-laravel-querykit/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (8)Versions (26)Used By (1)

Laravel Query Kit
=================

[](#laravel-query-kit)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4e0636aebeed2f147fa76f507797082870053267cf2a950370f4ba66896fbc3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616b6561626c65646b2f6c61726176656c2d71756572796b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/makeabledk/laravel-querykit)[![Build Status](https://camo.githubusercontent.com/fa873d9c5df356b772996230c01e1b723cf43ffeb7c2a0b905752fdbf2b93640/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d616b6561626c65646b2f6c61726176656c2d71756572792d6b69742f52756e25323074657374733f6c6162656c3d5465737473)](https://github.com/makeabledk/laravel-query-kit/actions)[![StyleCI](https://camo.githubusercontent.com/503173985ada737a4a9c15ecf3473a3c6605f034d7d2b9830db0b57034666338/68747470733a2f2f7374796c6563692e696f2f7265706f732f39353535313131342f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/95551114)

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
------------

[](#installation)

You can install this package via composer:

```
composer require makeabledk/laravel-querykit
```

For Laravel version prior 5.5: Add the service provider to your config/app.php:

```
'providers' => [
    ...
    Makeable\QueryKit\QueryKitServiceProvider::class,
];
```

Usage
-----

[](#usage)

Whenever you have a query scope on an Eloquent Model, you can apply the following trait to add QueryKit:

```
class Job extends Eloquent {
    use \Makeable\QueryKit\QueryKit;

    public function scopeHired($query)
    {
        return $query->whereIn('status', ['started', 'finished']);
    }
}
```

Out of the box Laravel offers us a convenient way to query against our database:

```
Job::hired()->first(); // a job with either 'started' or 'finished' status
```

But with query-kit you are now also able to check if a model instance passes a given scope:

```
$startedJob->passesScope('hired'); // true
$pendingJob->passesScope('hired'); // false
```

Pretty cool, right?

**Much more advanced functionality is supported than this simple example.**

See **Currently supported methods** further down.

Provided methods on `QueryKit`
------------------------------

[](#provided-methods-on-querykit)

### passesScope

[](#passesscope)

```
/**
 * Check if a model passes the given scope
 *
 * @param $name
 * @param array ...$args
 * @return bool
 */
public function passesScope($name, ...$args)
```

### failsScope

[](#failsscope)

```
/**
 * Check if a model fails the given scope
 *
 * @param $name
 * @param array ...$args
 * @return bool
 */
public function failsScope($name, ...$args)
```

Currently supported methods
---------------------------

[](#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
------------------

[](#extending-querykit)

Say that you want to add functionality for Laravel QueryBuilder's 'whereBetween' method:

Create a **WhereBetween** that implements **\\Makeable\\QueryKit\\Contracts\\QueryConstraint**.

```
class WhereBetween implements \Makeable\QueryKit\Contracts\QueryConstraint
{
    public function __construct(...$args)
    {
        // Accept scope arguments here
    }

    public function check($model)
    {
        // Return boolean
    }
}
```

Next register the constraint in your AppServiceProvider's register method:

```
public function register()
{
    \Makeable\QueryKit\Builder\Builder::registerConstraint(WhereBetween::class);
}
```

You can also use the above method to override the existing implementations.

Related packages
----------------

[](#related-packages)

Make sure to checkout our [makeabledk/laravel-eloquent-status](https://github.com/makeabledk/laravel-eloquent-status) package that streamlines the way you handle model-state across your application.

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Contributing
------------

[](#contributing)

We are happy to receive pull requests for additional functionality. Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Rasmus Christoffer Nielsen](https://github.com/rasmuscnielsen)
- [All Contributors](../../contributors)

License
-------

[](#license)

Attribution-ShareAlike 4.0 International. Please see [License File](LICENSE.md) for more information.

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance81

Actively maintained with recent releases

Popularity42

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 86.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~199 days

Recently: every ~379 days

Total

17

Last Release

102d ago

Major Versions

v0.9.0 → v1.0.02017-06-30

v1.2.2 → v2.0.02019-09-13

v2.3.0 → v3.0.02022-01-26

v3.0.0 → v4.0.02023-03-28

PHP version history (5 changes)v0.9.0PHP &gt;=7.0.0

v2.0.0PHP &gt;=7.2.0

v2.2.0PHP &gt;=7.3.0

v3.0.0PHP ^8.0

v4.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22741894?v=4)[Makeable ApS](/maintainers/makeabledk)[@makeabledk](https://github.com/makeabledk)

---

Top Contributors

[![rasmuscnielsen](https://avatars.githubusercontent.com/u/8465957?v=4)](https://github.com/rasmuscnielsen "rasmuscnielsen (56 commits)")[![mbardelmeijer](https://avatars.githubusercontent.com/u/1583095?v=4)](https://github.com/mbardelmeijer "mbardelmeijer (5 commits)")[![Belkadam](https://avatars.githubusercontent.com/u/5054775?v=4)](https://github.com/Belkadam "Belkadam (1 commits)")[![Christopher-Law](https://avatars.githubusercontent.com/u/25482861?v=4)](https://github.com/Christopher-Law "Christopher-Law (1 commits)")[![ottothebot](https://avatars.githubusercontent.com/u/261808813?v=4)](https://github.com/ottothebot "ottothebot (1 commits)")[![wilburpowery](https://avatars.githubusercontent.com/u/15817188?v=4)](https://github.com/wilburpowery "wilburpowery (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/makeabledk-laravel-querykit/health.svg)

```
[![Health](https://phpackages.com/badges/makeabledk-laravel-querykit/health.svg)](https://phpackages.com/packages/makeabledk-laravel-querykit)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.7k](/packages/illuminate-database)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[lemaur/eloquent-publishing

218.1k1](/packages/lemaur-eloquent-publishing)[laravel-liberu/laravel-gedcom

A package that converts gedcom files to Eloquent models

782.5k1](/packages/laravel-liberu-laravel-gedcom)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
