PHPackages                             joggapp/laravel-query-filters - 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. joggapp/laravel-query-filters

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

joggapp/laravel-query-filters
=============================

Cascading soft deletes for the Laravel PHP Framework

v3.0.0(2mo ago)027↑100%MITPHP

Since Jul 18Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/JoggApp/laravel-query-filters)[ Packagist](https://packagist.org/packages/joggapp/laravel-query-filters)[ RSS](/packages/joggapp-laravel-query-filters/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (3)Versions (5)Used By (0)

Introduction
------------

[](#introduction)

This package makes it easy to sort and filter Eloquent queries via an associative array of options, usually from a FormRequest class.

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

[](#installation)

Install the package via Composer:

```
composer require joggapp/laravel-query-filters
```

Usage
-----

[](#usage)

### Defining a QueryFilter

[](#defining-a-queryfilter)

Consider a `Product` model with `category`, `name`, and `price` fields.

We can apply sorting and filtering on these fields by defining a QueryFilter class. To create one, use the following command:

```
php artisan make:query-filter ProductQueryFilter
```

This command will create a new QueryFilter class in the `App\QueryFilters` directory.

Within this class, you can define the fields that can be sorted in ascending or descending order:

```
protected array $sortableFields = [
    'name',
    'price',
];
```

Specify the default sort and filtering options:

```
protected array $defaultFilters = [
    'sort_by' => 'price:asc,name:asc'
];
```

And define how a filter will be applied:

```
public function category(string|array $value)
{
    if (is_array($value)) {
        $query->whereIn('category', $value);
    } else {
        $query->where('category', $category);
    }
}
```

### Using QueryFilter Methods

[](#using-queryfilter-methods)

After defining the QueryFilter, it can be used to apply filter and sorting options:

```
use App\Model\Product;
use App\QueryFilters\ProductQueryFilter;

$filters = [
    'category' => 'Apparel',
    'sort_by' => 'price:asc,name:asc',
];

(new ProductQueryFilter())
    ->set($filters)
    ->apply(Product::query())
    ->get();
```

In this example, we are getting all products in the Apparel category sorted by price from low to high, then alphabetically by name.

### SortBy Validation Rule

[](#sortby-validation-rule)

Included in this package is a `SortBy` validation rule that can be used to help validate sort-by parameters:

```
use App\Models\Product;
use App\QueryFilters\ProductQueryFilter;
use Illuminate\Support\Facades\Validator;
use JoggApp\LaravelQueryFilters\Rules\SortBy;

$data = [
    'sort_by' => 'price:asc,name:asc',
];

$validator = Validator::make($data, [
    'sort_by' => ['sometimes', new SortBy()],
]);

$validated = $validator->validated();

$products = (new ProductQueryFilter())
    ->set($validated)
    ->apply(Product::query())
    ->get();
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance84

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~305 days

Total

3

Last Release

81d ago

Major Versions

v1.0.0 → v2.0.02025-03-26

v2.0.0 → v3.0.02026-03-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11228182?v=4)[Harish Toshniwal](/maintainers/introwit)[@introwit](https://github.com/introwit)

---

Top Contributors

[![introwit](https://avatars.githubusercontent.com/u/11228182?v=4)](https://github.com/introwit "introwit (2 commits)")[![danielluong](https://avatars.githubusercontent.com/u/6686376?v=4)](https://github.com/danielluong "danielluong (1 commits)")

---

Tags

laravelpackagejogg

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/joggapp-laravel-query-filters/health.svg)

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

###  Alternatives

[illuminate/database

The Illuminate Database package.

3.0k54.1M11.0k](/packages/illuminate-database)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8733.1M23](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

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

2051.4M2](/packages/glushkovds-phpclickhouse-laravel)[belamov/postgres-range

Postgres range types support for laravel

39238.6k2](/packages/belamov-postgres-range)[lemaur/eloquent-publishing

207.8k1](/packages/lemaur-eloquent-publishing)

PHPackages © 2026

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