PHPackages                             dsoloview/laravel-filters-sort - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dsoloview/laravel-filters-sort

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dsoloview/laravel-filters-sort
==============================

Laravel filters and sort

1.3.2(2y ago)214MITPHPPHP ^8

Since Oct 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/dsoloview/laravel-filters-sort)[ Packagist](https://packagist.org/packages/dsoloview/laravel-filters-sort)[ RSS](/packages/dsoloview-laravel-filters-sort/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (9)Used By (0)

Laravel easy filters and sort
=============================

[](#laravel-easy-filters-and-sort)

A small package that will allow you to easily and configurably filter and sort your query

Features
--------

[](#features)

- Customize sorting and filtering for each parameter
- Easy to set default options
- Structures the code
- Easily expandable

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

[](#installation)

Install dsoloview/laravel-filters-sort from composer

```
  composer require dsoloview/laravel-filters-sort
```

Usage
-----

[](#usage)

- [Model](#Model)
- [Filter](#Filter)
- [Sort](#Sort)
- [Usage](#Usage)

### Model

[](#model)

For the model, you need to add traits **HasFilters** and **HasSort**[![Model](https://camo.githubusercontent.com/9d56e711c8eecbdcc836ce0bbe731c833916ea311bbbc71a38099185b5e3f908/68747470733a2f2f7261772e6769746875622e636f6d2f64736f6c6f766965772f6c61726176656c2d66696c746572732d736f72742f6d61737465722f73637265656e73686f74732f4d6f64656c2e706e67)](https://camo.githubusercontent.com/9d56e711c8eecbdcc836ce0bbe731c833916ea311bbbc71a38099185b5e3f908/68747470733a2f2f7261772e6769746875622e636f6d2f64736f6c6f766965772f6c61726176656c2d66696c746572732d736f72742f6d61737465722f73637265656e73686f74732f4d6f64656c2e706e67)

### Filter

[](#filter)

Create filter class for your model and extends it from *dsoloview\\LaravelFiltersSort\\Filters\\QueryFilter*

Сreate a method for each parameter you will receive from the filter request

**For example**:

`applicaitons?filters[categories][]=7&filters[search]=myApp`

[![Filter](https://camo.githubusercontent.com/522f2e42e18f0c82088ca2d5a6c7a37f864e0035c76049f6488cba16d3206e6f/68747470733a2f2f7261772e6769746875622e636f6d2f64736f6c6f766965772f6c61726176656c2d66696c746572732d736f72742f6d61737465722f73637265656e73686f74732f46696c746572732e706e67)](https://camo.githubusercontent.com/522f2e42e18f0c82088ca2d5a6c7a37f864e0035c76049f6488cba16d3206e6f/68747470733a2f2f7261772e6769746875622e636f6d2f64736f6c6f766965772f6c61726176656c2d66696c746572732d736f72742f6d61737465722f73637265656e73686f74732f46696c746572732e706e67)

### Sort

[](#sort)

Create sort class for your model and extends it from *dsoloview\\LaravelFiltersSort\\Sort\\QuerySort*

Сreate a method for each parameter you will receive from the sort request

**For example**:

`applicaitons?sort=id&direction=asc`

[![Sort](https://camo.githubusercontent.com/4b5da003f4d592c09a4e9bcd3d0a59b0f3bc950f8747732f0e1e91e114b22e5b/68747470733a2f2f7261772e6769746875622e636f6d2f64736f6c6f766965772f6c61726176656c2d66696c746572732d736f72742f6d61737465722f73637265656e73686f74732f536f72742e706e67)](https://camo.githubusercontent.com/4b5da003f4d592c09a4e9bcd3d0a59b0f3bc950f8747732f0e1e91e114b22e5b/68747470733a2f2f7261772e6769746875622e636f6d2f64736f6c6f766965772f6c61726176656c2d66696c746572732d736f72742f6d61737465722f73637265656e73686f74732f536f72742e706e67)

You can set default param for sort

`protected const SORT_DEFAULT = 'param'`

And for direction

`protected const DIRECTION_DEFAULT = 'asc|desc'`

### Usage

[](#usage-1)

Traits add scopes `filter(QueryFilter)` and `sort(QuerySort)` to your model

[![Usage](https://camo.githubusercontent.com/f891422248fb73808934e9934061a38fd5ca19cede75bff422f50861ca55a572/68747470733a2f2f7261772e6769746875622e636f6d2f64736f6c6f766965772f6c61726176656c2d66696c746572732d736f72742f6d61737465722f73637265656e73686f74732f55736167652e706e67)](https://camo.githubusercontent.com/f891422248fb73808934e9934061a38fd5ca19cede75bff422f50861ca55a572/68747470733a2f2f7261772e6769746875622e636f6d2f64736f6c6f766965772f6c61726176656c2d66696c746572732d736f72742f6d61737465722f73637265656e73686f74732f55736167652e706e67)

You can pass your filter and sort classes to scopes like in the screenshot.

After it you can make `get()` or `paginate()` like in example.

Support
-------

[](#support)

For support, telegram **@dsoloview**.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Recently: every ~64 days

Total

7

Last Release

1034d ago

### Community

Maintainers

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

---

Top Contributors

[![dsoloview](https://avatars.githubusercontent.com/u/89259621?v=4)](https://github.com/dsoloview "dsoloview (14 commits)")

---

Tags

laravelsortfilters

### Embed Badge

![Health badge](/badges/dsoloview-laravel-filters-sort/health.svg)

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

###  Alternatives

[kyslik/column-sortable

Package for handling column sorting in Laravel 6.x

6485.6M21](/packages/kyslik-column-sortable)[tormjens/eventy

The WordPress filter/action system in Laravel

438912.9k16](/packages/tormjens-eventy)[square1/nova-metrics

Add support for resource-filters on your laravel nova metrics

27278.7k](/packages/square1-nova-metrics)[indexzer0/eloquent-filtering

Powerful eloquent filtering

22425.9k3](/packages/indexzer0-eloquent-filtering)[lifeonscreen/nova-sort-relations

This package improves support for sorting relations in Laravel Nova.

2081.9k](/packages/lifeonscreen-nova-sort-relations)

PHPackages © 2026

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