PHPackages                             ahmadaldali/filter-lists - 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. ahmadaldali/filter-lists

ActiveLibrary

ahmadaldali/filter-lists
========================

Make dealing with lists easier

0.4(10mo ago)213MITPHP

Since Apr 25Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/ahmadaldali/filter-lists)[ Packagist](https://packagist.org/packages/ahmadaldali/filter-lists)[ RSS](/packages/ahmadaldali-filter-lists/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

Filter Lists
============

[](#filter-lists)

**filter-lists** is a Laravel package designed to simplify filtering, sorting, and paginating Eloquent collections or query results. It is particularly useful for APIs or backend systems where you need dynamic filtering on model collections with minimal setup.

---

Features
--------

[](#features)

- Pagination support with `page` and `limit`.
- Sorting by any column with `sortBy` and order direction via `desc`.
- Filtering by model columns (e.g., `name`, `email`, `is_admin`).
- Date range filtering by `dateRange` attribute (filter records between two dates).
- Fixed range filtering by `fixRange` attribute (today, current month, or current year).

---

Requirements
------------

[](#requirements)

- Laravel Framework `>= 8`

---

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

[](#installation)

Install via Composer in your Laravel project root:

```
composer require ahmadaldali/filter-lists
```

Usage
-----

[](#usage)

### Step 1: Import Trait

[](#step-1-import-trait)

```
use AhmadAldali\FilterLists\Traits\FilterableResponse;
```

### Step 2: Use in your Controller or Service

[](#step-2-use-in-your-controller-or-service)

```
class UserController extends Controller
{
    use FilterableResponse;

    public function index(Request $request)
    {
        // Retrieve your collection or query builder
        $collection = User::all();

        // Apply filtering, sorting, and pagination based on request
        $results = $this->applyFilters($collection, $request);

        return response()->json($results);
    }
}
```

Filters &amp; Parameters
------------------------

[](#filters--parameters)

ParameterTypeDescriptionExample`page`integerPage number for pagination`page=2``limit`integerNumber of records per page`limit=10``sortBy`stringColumn name to sort by`sortBy=created_at``desc`booleanSort direction: `true` for descending, `false` for ascending`desc=true`Filtering by model columns
--------------------------

[](#filtering-by-model-columns)

You can filter the list by any valid column of your model, for example:

```
?name=John&email=john@example.com&is_admin=1
```

This will apply WHERE conditions on those columns.

Date Range Filter
-----------------

[](#date-range-filter)

Use the `dateRange` parameter with JSON containing `from` and `to` dates to filter records created within that range.

```
{
  "dateRange": {
    "from": "2023-01-01",
    "to": "2023-01-31"
  }
}
```

Fixed Range Filter
------------------

[](#fixed-range-filter)

Filter by fixed time ranges with the fixRange parameter. Allowed values:

- today — records created today.
- monthly — records created this month.
- yearly — records created this year.

Example

```
?fixRange=today
```

Example
-------

[](#example)

I created a route on my test application, that's called */list*.

In that route, I executed an action in a controller that contains the previous **Usage**.

**Get all results**

[![alt text](https://github.com/ahmadaldali/filter-lists/raw/main/images/1%20git%20all%20results.png)](https://github.com/ahmadaldali/filter-lists/blob/main/images/1%20git%20all%20results.png)

**Apply limit**

[![alt text](https://github.com/ahmadaldali/filter-lists/raw/main/images/2%20apply%20limit.png)](https://github.com/ahmadaldali/filter-lists/blob/main/images/2%20apply%20limit.png)

**Apply limit with page**

[![alt text](https://github.com/ahmadaldali/filter-lists/raw/main/images/3%20apply%20limit%20with%20page.png)](https://github.com/ahmadaldali/filter-lists/blob/main/images/3%20apply%20limit%20with%20page.png)

**Apply condition**

[![alt text](https://github.com/ahmadaldali/filter-lists/raw/main/images/4%20apply%20condition%20on%20column's%20name.png)](https://github.com/ahmadaldali/filter-lists/blob/main/images/4%20apply%20condition%20on%20column's%20name.png)

**Apply condition with wrong value**

[![alt text](https://github.com/ahmadaldali/filter-lists/raw/main/images/5%20apply%20condition%20with%20wrong%20value.png)](https://github.com/ahmadaldali/filter-lists/blob/main/images/5%20apply%20condition%20with%20wrong%20value.png)

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

[](#contributing)

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

Welcome to any suggestion.

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance56

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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 ~577 days

Total

3

Last Release

321d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0350dd538cc9117f9a56a89589f43c94f771bea69b679e69f5050df995baea6?d=identicon)[ahmadaldali](/maintainers/ahmadaldali)

---

Top Contributors

[![ahmadaldali](https://avatars.githubusercontent.com/u/32056043?v=4)](https://github.com/ahmadaldali "ahmadaldali (23 commits)")

### Embed Badge

![Health badge](/badges/ahmadaldali-filter-lists/health.svg)

```
[![Health](https://phpackages.com/badges/ahmadaldali-filter-lists/health.svg)](https://phpackages.com/packages/ahmadaldali-filter-lists)
```

PHPackages © 2026

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