PHPackages                             michaelnabil230/laravel-query-conditions - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. michaelnabil230/laravel-query-conditions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

michaelnabil230/laravel-query-conditions
========================================

This is my package laravel-query-conditions

v1.0.0(3y ago)341[2 PRs](https://github.com/michaelnabil230/laravel-query-conditions/pulls)MITJavaScriptPHP ^8.1

Since Jul 7Pushed 2y ago2 watchersCompare

[ Source](https://github.com/michaelnabil230/laravel-query-conditions)[ Packagist](https://packagist.org/packages/michaelnabil230/laravel-query-conditions)[ Docs](https://github.com/michaelnabil230/laravel-query-conditions)[ RSS](/packages/michaelnabil230-laravel-query-conditions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (4)Used By (0)

This is my package laravel-query-conditions
===========================================

[](#this-is-my-package-laravel-query-conditions)

[![Latest Version on Packagist](https://camo.githubusercontent.com/932e7e43d233132b3b6e93935031e95acfecce3ee2dae55d6d93171c60ad7cd8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d69636861656c6e6162696c3233302f6c61726176656c2d71756572792d636f6e646974696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/michaelnabil230/laravel-query-conditions)[![GitHub Tests Action Status](https://camo.githubusercontent.com/d25588d34c854e0b2ed30ccf3e1f4aeb8a4d91708fe00de32c2ce1c6a39cc1ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d69636861656c6e6162696c3233302f6c61726176656c2d71756572792d636f6e646974696f6e732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/michaelnabil230/laravel-query-conditions/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/fcb307682c5a428576fea1817b8f57a60a263013be4931e9b14b2f38e21a23c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d69636861656c6e6162696c3233302f6c61726176656c2d71756572792d636f6e646974696f6e732f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/michaelnabil230/laravel-query-conditions/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/fe7d0a0d61c91935ef5dc33cead85781f03576d72495338de7673d939ab1972f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d69636861656c6e6162696c3233302f6c61726176656c2d71756572792d636f6e646974696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/michaelnabil230/laravel-query-conditions)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require michaelnabil230/laravel-query-conditions
```

Preparing your model
--------------------

[](#preparing-your-model)

To associate query condonation with a model, the model must implement the following interface and trait:

```
use Illuminate\Database\Eloquent\Model;
use MichaelNabil230\QueryConditions\Support\Condition;
use MichaelNabil230\QueryConditions\Concerns\HasQueryCondonation;
use MichaelNabil230\QueryConditions\Interfaces\QueryCondonation as InterfacesQueryCondonation;
use Illuminate\Database\Eloquent\Builder;

class YourModel extends Model implements InterfacesQueryCondonation
{
    use HasQueryCondonation;

    public function parseQBRule(Builder $query, Condition $condition, string $method): void
    {
        if ($condition->rule === 'age') {
            $query->{$method}('age', $condition->operator, $condition->value);
        }

        if ($condition->rule === 'created_at') {
            $query->{$method}('created_at', $condition->operator, $condition->value);
        }
    }
}
```

Preparing Vue
-------------

[](#preparing-vue)

```
import './bootstrap';

window.Vue = require('vue').default;

import QueryBuilder from './components/QueryBuilder.vue'

const app = new Vue({
    el: '#app',
    components: { QueryBuilder },
    methods: {
        getResults: function () {
            axios.post('/results', { query: this.query }).then(response => {
                this.results = response.data;
                console.log({ response });
            });
        }
    },
    data() {
        return {
            query: {},
            rules: [
                {
                    type: "numeric",
                    id: "age",
                    label: "Age"
                },
                {
                    type: "select",
                    id: "job_title",
                    label: "Job Title",
                    choices: [
                        { label: 'Regional Manager', value: 'Regional Manager' },
                        { label: 'Assistant to the Regional Manager', value: 'Assistant to the Regional Manager' },
                        { label: 'Sales Associate', value: 'Sales Associate' },
                    ]
                },
                {
                    type: "numeric",
                    id: "has_orders",
                    label: "has Orders",
                    operators: ['=', '>=']
                },
            ],
        };
    }
});
```

First call the directive in blade or vue (and pass condonations):

Now
---

[](#now)

```

```

The next version
----------------

[](#the-next-version)

```
    $condonations = [
        Text::make('Name'),
        Number::make('Age')->min(1)->max(1000),
        Select::make('Job title', 'job_title')->options([
            'R' => 'Regional Manager',
            'A' => 'Assistant to the Regional Manager',
            'S' => 'Sales Associate',
        ])
    ];
```

```

        let condonations = @json($condonations)

```

Final go to controller
----------------------

[](#final-go-to-controller)

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use MichaelNabil230\QueryConditions\QueryConditions;
use App\Models\User;

class ConditionController extends Controller
{
    public function getDataFromQueryConditions(Request $request)
    {
        $users = QueryConditions::for(User::class, $request->input('query'))
            ->get();

        return [
            'users' => $users,
        ];
    }
}
```

Some screenshots of the package it is a best package
----------------------------------------------------

[](#some-screenshots-of-the-package-it-is-a-best-package)

[![](./screenshots/simpleQuery.png)](./screenshots/simpleQuery.png)

TODOS
-----

[](#todos)

- Format the documents
- Add groupe in to conditions
- Test a complicated query
- Implement `Fields` classes in to FrontEnd
- Add unit tests

Testing
-------

[](#testing)

```
composer test
```

Support
-------

[](#support)

[![](.assets/ko-fi.png)](https://ko-fi.com/michaelnabil230)[![](.assets/buymeacoffee.png)](https://www.buymeacoffee.com/michaelnabil230)[![](.assets/paypal.png)](https://www.paypal.com/paypalme/MichaelNabil23)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Michael Nabil](https://github.com/michaelnabil230)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.8% 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

Unknown

Total

1

Last Release

1406d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0bead4c51d39cf34d71f1156ce2d8a94be322f1dbd46578763f7720365c904c7?d=identicon)[michael.nabil230](/maintainers/michael.nabil230)

---

Top Contributors

[![michaelnabil230](https://avatars.githubusercontent.com/u/46572405?v=4)](https://github.com/michaelnabil230 "michaelnabil230 (24 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")

---

Tags

laravelphptailwindcssvuelaravelMichaelNabil230laravel-query-conditions

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/michaelnabil230-laravel-query-conditions/health.svg)

```
[![Health](https://phpackages.com/badges/michaelnabil230-laravel-query-conditions/health.svg)](https://phpackages.com/packages/michaelnabil230-laravel-query-conditions)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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