New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

jurager/filterable

Laravel package for building complex eloquent filters in a simple, structured way
1,263
Install
composer require jurager/filterable
Latest Version:1.9.2
PHP:^8.4
Laravel:11 · 12 · 13
License:MIT
Last Updated:Sep 9, 2026
Links: GitHub  ·  Packagist
Maintainer: Jurager

Jurager/Filterable

Latest Stable Version Total Downloads PHP Version Require License Ko-fi

A Laravel package that adds JSON:API-compatible filter and sort query parameter support to Eloquent models.

Features:

  • Declarative $filterable and $sortable arrays on the model — no boilerplate controllers
  • Full operator set: eq, ne, gt, gte, lt, lte, like, in, nin, null, not_null, between, not_between, tree
  • Relation filtering via whereHas subqueries and pivot column support
  • Filtered eager-loading with filter[included.*]
  • OR / AND condition groups
  • Field, relation, and sort resolver interfaces for custom SQL
  • Full-result caching (Redis / Memcached) with automatic tag-based invalidation
  • Custom field, relation, and sort resolvers for extending filter behaviour
  • Tree descendant expansion via the tree operator

Requirements

  • PHP 8.2+
  • Laravel 11+

Installation

composer require jurager/filterable

Add HasFilterable to your model and declare allowed fields:

use Jurager\Filterable\Concerns\HasFilterable;

class Product extends Model
{
    use HasFilterable;

    protected array $filterable = [
        'sku'             => ['eq', 'like'],
        'price'           => ['gte', 'lte', 'between'],
        'status'          => ['eq', 'in'],
        'category.name'   => ['eq', 'like'],
        'is_active',
    ];

    protected array $sortable = ['id', 'sku', 'price', 'created_at'];
}

Apply in the controller:

Product::query()
    ->filter(request()->query('filter', []))
    ->sort(request()->query('sort'))
    ->paginate();

Request:

GET /products?filter[status][in][]=active&filter[price][gte]=100&sort=-created_at

Documentation

To learn more about filtering, sorting, relations, caching, and advanced usage please go to the Documentation.

License

This package is open-sourced software licensed under the MIT license.

Related Packages

jerome/filterable

Streamline dynamic Eloquent query filtering with seamless API request integratio...

52,676 194
rmasters/filter

Makes input and output filtering Eloquent models easy

1,506 21
macellan/filter

Makes input and output filtering Eloquent models easy

1,169 0
bcalik/filter

Makes input and output filtering Eloquent models easy

529 1
mayoz/eloquent-filterable

Query filter for your Eloquent models.

120 9

Version History

Version Released PHP Laravel License
1.9.2 ^8.4 ^11.0|^12.0|^13.0 MIT
1.9.1 ^8.4 ^11.0|^12.0|^13.0 MIT
1.9 ^8.4 ^11.0|^12.0|^13.0 MIT
1.8 ^8.4 ^11.0|^12.0|^13.0 MIT
1.7 ^8.4 ^11.0|^12.0|^13.0 MIT