PHPackages                             aw-studio/laravel-model-index - 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. [API Development](/categories/api)
4. /
5. aw-studio/laravel-model-index

ActiveLibrary[API Development](/categories/api)

aw-studio/laravel-model-index
=============================

Filterable, sortable, searchable index listing for laravel models

0.1.3(12mo ago)0698↓50%MITPHP

Since Jan 14Pushed 5mo agoCompare

[ Source](https://github.com/aw-studio/laravel-model-index)[ Packagist](https://packagist.org/packages/aw-studio/laravel-model-index)[ Docs](https://github.com/aw-studio/model-index)[ RSS](/packages/aw-studio-laravel-model-index/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (4)Used By (0)

Laravel Model Index
===================

[](#laravel-model-index)

[![image](https://private-user-images.githubusercontent.com/36259611/401593418-7b2c2587-6378-4a4e-a142-a692cfde7de9.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzIyNjk3NTUsIm5iZiI6MTc3MjI2OTQ1NSwicGF0aCI6Ii8zNjI1OTYxMS80MDE1OTM0MTgtN2IyYzI1ODctNjM3OC00YTRlLWExNDItYTY5MmNmZGU3ZGU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMjI4VDA5MDQxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZhMDQzMjQ2NmUxNDI3ZjI2MTljOTYzZmE5YzRlYjBjYWMzZjU2NDliZjhmMmM5NTYyY2JhOGUzNjA2MDM0ZWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.C_1h1yDH5C-U0Nt8kzSNPSxXk3B_4T7B_RZJhXVoO5U)](https://private-user-images.githubusercontent.com/36259611/401593418-7b2c2587-6378-4a4e-a142-a692cfde7de9.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzIyNjk3NTUsIm5iZiI6MTc3MjI2OTQ1NSwicGF0aCI6Ii8zNjI1OTYxMS80MDE1OTM0MTgtN2IyYzI1ODctNjM3OC00YTRlLWExNDItYTY5MmNmZGU3ZGU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMjI4VDA5MDQxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZhMDQzMjQ2NmUxNDI3ZjI2MTljOTYzZmE5YzRlYjBjYWMzZjU2NDliZjhmMmM5NTYyY2JhOGUzNjA2MDM0ZWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.C_1h1yDH5C-U0Nt8kzSNPSxXk3B_4T7B_RZJhXVoO5U)

Overview
--------

[](#overview)

This package provides an easy to use Query Builder to filter, sort, search, and paginate Laravel models.

Usage
-----

[](#usage)

Install the package via composer:

```
composer require aw-studio/laravel-model-index
```

The model to which the index endpoint refers must have the following trait added:

```
use AwStudio\ModelIndex\Traits\HasIndexQuery;

class MyModel extends EloquentModel {

    use HasIndexQuery;

}
```

### Filtering

[](#filtering)

The Index Query Builder supports filtering from query parameters nearly out of the box. All you have to do is to configure which model attributes are filterable. This can be done when using the index in the controller:

```
public function index(Request $request){
    MyModel::index()
            ->filterable(['name', 'age']
            ->get();
}
```

Or if you'd like to resue the Index multiple times and always have the same filter options enabled, you may add a `filterable` property or method to the Model which should return an array attribute names.

Filtering the index list is now as simple as adding the query parameter “filter” to the URL with the attribute name as the key and a value. For example:

```
http://localhost?filter[name]=John

// or

http://localhost?filter[age]=30
```

#### Advanced Filtering

[](#advanced-filtering)

For more sophisticated filters, you may use operators and logical operators in the query parameters. For example:

```
http://localhost?filter[age][$gte]=18&filter[age][$lte]=30
```

The following operators are supported:

- `$eq` - Equal
- `$ne` - Not equal
- `$gt` - Greater than
- `$gte` - Greater than or equal
- `$lt` - Less than
- `$lte` - Less than or equal
- `$in` - In
- `$notIn` - Not in
- `$contains` - Contains
- `$notContains` - Not contains
- `$between` - Between
- `$startsWith` - Starts with
- `$endsWith` - Ends with
- `$null` - Null
- `$notNull` - Not null

Logical operators can be used to combine filters. For example:

```
http://localhost?filter[$or][0][name][$contains]=John&filter[$or][1][name][$contains]=Doe
```

The following logical operators are supported:

- `$and`
- `$or`

#### Custom Filters

[](#custom-filters)

By default filter keys are supposed to match the column names of the model. You can also define custom filter keys by using the `filter` method on the Index query and define custom callbacks for the filter. This also allows you to use model scopes for filtering or more complex queries e.g. in related models.

```
public function index(Request $request)
{
    // http://localhost?filter[popular]=true
    return User::index()
        ->filter('popular', fn($query, $value) => $query->popular())
        ->get();

    // http://localhost?filer[user.name]=John
    return Post::index()
        ->filter('user.name', function ($query, $value) {
            $query->whereHas('user', fn($query) => $query->where('name', $value));
        })
        ->get();
}
```

### Sorting

[](#sorting)

You can sort the index using query parameters. For example:

```
http://localhost?sort=name
```

You can also sort in descending order:

```
http://localhost?sort=-name

// or

http://localhost?sort=name:desc
```

Multiple columns can be sorted by separating them with a comma:

```
http://localhost?sort=name,-age
```

### Searching

[](#searching)

You can search the index using query parameters. For example:

```
http://localhost?search=John
```

This will search all configured columns for the term "John".

#### Configuring Searchable Columns

[](#configuring-searchable-columns)

To configure which columns should be searchable, use the `searchable` method on the Index query:

```
public function index(Request $request)
{
    return User::index()
        ->searchable(['name', 'email'])
        ->get();
}
```

### Pagination

[](#pagination)

You can automatically paginate the index using query parameters by adding the `page` query parameter to the URL or setting a per\_page value in the query parameters. For example:

```
http://localhost?page=2

// or

http://localhost?perPage=10
```

License
-------

[](#license)

This project is licensed under the MIT License. See the LICENSE file for details.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance62

Regular maintenance activity

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 77.3% 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 ~118 days

Total

2

Last Release

364d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b2d65d58480dd7fdbf4f4593158cbd0634550ee9210c49957cc48c8a8ccaef6?d=identicon)[jannescb](/maintainers/jannescb)

---

Top Contributors

[![lpheller](https://avatars.githubusercontent.com/u/36259611?v=4)](https://github.com/lpheller "lpheller (17 commits)")[![jannescb](https://avatars.githubusercontent.com/u/17292622?v=4)](https://github.com/jannescb "jannescb (5 commits)")

---

Tags

apilaravelquery-builderlaravelquery builderaw-studiomodel-index

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/aw-studio-laravel-model-index/health.svg)

```
[![Health](https://phpackages.com/badges/aw-studio-laravel-model-index/health.svg)](https://phpackages.com/packages/aw-studio-laravel-model-index)
```

###  Alternatives

[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[flat3/lodata

OData v4.01 Producer for Laravel

96320.9k](/packages/flat3-lodata)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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