PHPackages                             patienceman/filtan - 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. patienceman/filtan

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

patienceman/filtan
==================

Filtan is Laravel Http QueryFilter package designed to simplify and enhance the process of filtering queries by reading http queries. It enables developers to apply filters to queries and customize the results based on dynamic http parameters. By integrating Filtan into your Laravel project, you can build complex and flexible filtering mechanisms for your request effortlessly.

1.0.9(2y ago)23.0k1MITPHP

Since Jul 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/patiencemanzen/Filtan)[ Packagist](https://packagist.org/packages/patienceman/filtan)[ Docs](https://github.com/patiencemanzen/Filtan)[ RSS](/packages/patienceman-filtan/feed)WikiDiscussions main Synced today

READMEChangelog (10)DependenciesVersions (9)Used By (0)

Laravel Filtan
==============

[](#laravel-filtan)

Simplifying Laravel Eloquent Query Filtering

Filtan is a Laravel QueryFilter package that simplifies and improves the process of filtering Eloquent queries. It allows developers to easily apply filters to queries and customize the results based on dynamic parameters. By integrating Filtan into your Laravel project, you can effortlessly create complex and flexible filtering mechanisms for your models.

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

[](#installation)

To install the package, simply run the following command in your Laravel terminal:

```
composer require patienceman/filtan
```

Configuration
-------------

[](#configuration)

After installing the package, you need to publish the configuration file. Run the following command to publish the configuration file:

```
php artisan filtan:config
```

This will create a `filtan.php` file in your config directory. You can customize the default directory for your filters in this configuration file.

Usage
-----

[](#usage)

We all love automated tasks like artisan commands. With Filtan, you can generate filter files with just one command. No need to manually create filter files!

```
php artisan filtan:create {filter} --model={model}
```

This command will create a filter file for you in the default directory specified in your configuration.

Just one command 🎉 Let us use our example of the AirPlane Model and create a new filter:

```
php artisan filtan:create AirPlaneFilter --model=AirPlane
```

This will create the filter file in:

```
app/Http/QueryFilters/AirPlaneFilter.php
```

```
namespace App\Http\QueryFilters;

use Patienceman\Filtan\QueryFilter;

class AirPlaneFilter extends QueryFilter {
    /**
     * Search specific values from Airplan by name
     *
     * @param string $query
     */
    public function query(string $query) {
        $this->builder->where('name', 'LIKE', '%' . $query . '%');
    }
}
```

You can also specify a custom path for your filter. Just add the path in front of your filter name. Let's take our current example:

```
php artisan filtan:create Model/AirPlaneFilter
```

In your App/Services/Filters directory, Where are you gonna put all of your model filter files?

```
namespace App\Http\QueryFilters\Model;

use Patienceman\Filtan\QueryFilter;

class AirPlaneFilter extends QueryFilter {
    /**
     * Search specific values from industry by name
     *
     * @param string $query
     */
    public function query(string $query) {
        $this->builder->where('name', 'LIKE', '%' . $query . '%');
    }
}
```

Now you have your filter function to be applied when a new AirplaneModel query is called!

We need to communicate to the model and tell it that we have filters, so that we can call it anytime! Use the `Filterable` trait to enable the filter builder.

```
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Patienceman\Filtan\Filterable;

class Airplane extends Model {
    use HasFactory, Filterable;
}
```

From now on, we are able to call our filter anytime, any place that needs the Airplane model. Let's see how we can use this in our controller:

```
namespace App\Http\Controllers\ApiControllers;

use App\Http\Controllers\Controller;
use App\Models\User;
use App\Services\Filters\CompanyFilter;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class AirplaneController extends Controller {
    /**
     * Display a listing of the resource.
     *
     * @return JsonResponse
     */
    public function index(CompanyFilter $filter): JsonResponse {
        $planes = Airplane::filter($filter)->get();

        return response()->json([
            'data' => $planes,
            'message' => 'Airplanes retrieved successfully'
        ]);
    }
}
```

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

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

1. Fork the repository and create a new branch for your contributions.
2. Make your changes or additions, adhering to the coding guidelines.
3. Submit a pull request detailing your changes, and our team will review it promptly.

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~80 days

Recently: every ~111 days

Total

8

Last Release

823d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90353f39cc87c27ae67eb7503409539cb8fe8f879fa749cb3e51458cad85c00c?d=identicon)[Manirabona-patience](/maintainers/Manirabona-patience)

---

Top Contributors

[![patiencemanzen](https://avatars.githubusercontent.com/u/55847682?v=4)](https://github.com/patiencemanzen "patiencemanzen (52 commits)")

---

Tags

composereloquentlaravelphp8symfonyphpsearchlaraveldatabasemodeleloquentqueryfilterfiltanpatienceman

### Embed Badge

![Health badge](/badges/patienceman-filtan/health.svg)

```
[![Health](https://phpackages.com/badges/patienceman-filtan/health.svg)](https://phpackages.com/packages/patienceman-filtan)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)

PHPackages © 2026

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