PHPackages                             devchithu/laravel-filter-sorting-searchable - 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. [Search &amp; Filtering](/categories/search)
4. /
5. devchithu/laravel-filter-sorting-searchable

ActivePackage[Search &amp; Filtering](/categories/search)

devchithu/laravel-filter-sorting-searchable
===========================================

This package used to filter, sorting(asc, desc), searchable. php version 7.2^

v1.2.8(2y ago)0304MITJavaScriptPHP ^7.2|^8.0

Since Jul 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/chithresudev/laravel-filter-sorting-searchable)[ Packagist](https://packagist.org/packages/devchithu/laravel-filter-sorting-searchable)[ RSS](/packages/devchithu-laravel-filter-sorting-searchable/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)DependenciesVersions (11)Used By (0)

laravel Devchithu-Filter-Sorting-Searchable
===========================================

[](#laravel-devchithu-filter-sorting-searchable)

[![Latest Stable Version](https://camo.githubusercontent.com/55c39a57d320f6ac9ed74340f82cf18b613c4ef0c9d9e4de02f8504bd848e962/687474703a2f2f706f7365722e707567782e6f72672f6465766368697468752f6c61726176656c2d66696c7465722d736f7274696e672d73656172636861626c652f76)](https://packagist.org/packages/devchithu/laravel-filter-sorting-searchable) [![Total Downloads](https://camo.githubusercontent.com/3dcd7b0ef90f868cfd4ec1f5a5a0f2ad6e3f6545116071ecd0d4e1660670a098/687474703a2f2f706f7365722e707567782e6f72672f6465766368697468752f6c61726176656c2d66696c7465722d736f7274696e672d73656172636861626c652f646f776e6c6f616473)](https://packagist.org/packages/devchithu/laravel-filter-sorting-searchable) [![Latest Unstable Version](https://camo.githubusercontent.com/5345c7b16a0580158d4c80940b52db5f10a7349bd4ade38d0f3d8289e44cde2f/687474703a2f2f706f7365722e707567782e6f72672f6465766368697468752f6c61726176656c2d66696c7465722d736f7274696e672d73656172636861626c652f762f756e737461626c65)](https://packagist.org/packages/devchithu/laravel-filter-sorting-searchable) [![License](https://camo.githubusercontent.com/96b3b60de494c05e7efb7beb630497396058cbf76b68c75d28233758dee85d0a/687474703a2f2f706f7365722e707567782e6f72672f6465766368697468752f6c61726176656c2d66696c7465722d736f7274696e672d73656172636861626c652f6c6963656e7365)](https://packagist.org/packages/devchithu/laravel-filter-sorting-searchable) [![PHP Version Require](https://camo.githubusercontent.com/0e779953ef11681e63abca95bbe056ff15ad1bd4d06e9f7447d3f20cb9d43612/687474703a2f2f706f7365722e707567782e6f72672f6465766368697468752f6c61726176656c2d66696c7465722d736f7274696e672d73656172636861626c652f726571756972652f706870)](https://packagist.org/packages/devchithu/laravel-filter-sorting-searchable)

This Package for handling dynamic column sorting, filter and searchable in Laravel.

[![Screenshot](public/filter_sort_searchable.gif)](public/filter_sort_searchable.gif)

Installation &amp; Usages
-------------------------

[](#installation--usages)

### Basic Setup

[](#basic-setup)

Install via composer; in console:

```
composer require devchithu/laravel-filter-sorting-searchable

```

or require in *composer.json*:

```
{
    "require": {
        "devchithu/laravel-filter-sorting-searchable": "^1.0"
    }
}
```

then run `composer update` in your terminal to pull it in.

Once this has finished, you will need to add the service provider to the providers array in your app.php config as follows:

path : project/config/app.php

Find 'providers=&gt;\[\]' add inside below code (Custom Service Providers...)

```
Devchithu\LaravelFilterSortingSearchable\Providers\FilterSortingSearchableProvider::class,
```

Example like code : project/config/app.php

```
'providers' => [

    App\Providers\RouteServiceProvider::class,

    /*
     * Third Party Service Providers...
     */
    Devchithu\LaravelFilterSortingSearchable\Providers\FilterSortingSearchableProvider::class,
],
```

### Usages

[](#usages)

Use **FilterSortSearchable** trait inside your *Eloquent* model(s).

```
use Devchithu\LaravelFilterSortingSearchable\Traits\FilterSortingSearchable;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, FilterSortingSearchable;
    ...
    ...
}
```

### Font Awesome 6.4^ (default font classes)

[](#font-awesome-64-default-font-classes)

Install [Font-Awesome](https://fontawesome.com/icons/) Search "sort" in [cheatsheet](https://fontawesome.com/icons/) and see used icons yourself.

```

```

Completed.

### Bootstrap 5 version

[](#bootstrap-5-version)

CSS File

```

```

JS File

```

```

Publish Js file
---------------

[](#publish-js-file)

then run publish cmd you must to publish only js file and where-ever your want 'filter, sort, searchable' using the below script in blade.php file

```
php artisan vendor:publish --tag=filter-sorting-searchable

```

See public/filter-sorting-searchable.js (if you want any change update this code inside)

Two method of design filter sorting extension
=============================================

[](#two-method-of-design-filter-sorting-extension)

#### 1. Bootstrap Inline filter sorting Blade Extension

[](#1-bootstrap-inline-filter-sorting-blade-extension)

#### 2. Bootstrap filter using Modal, Offcanvas Blade Extension

[](#2-bootstrap-filter-using-modal-offcanvas-blade-extension)

Two Type of blade extension using script file.

1. Bootstrap Inline filter sorting Blade Extension
--------------------------------------------------

[](#1-bootstrap-inline-filter-sorting-blade-extension-1)

Must push that js file in blade, where-ever your want like (better than push that js file into main index blade.php):

```

```

OR,

```
@push('scripts')

@endpush

```

\* Sorting
----------

[](#-sorting)

There is a blade extension for you to use **@filterSort()**

```
@filterSort(['sorting' => true,'field_name' => 'name'])
```

**Custom field name sorting**

```
@filterSort(['sorting' => true,'field_name' => 'name', 'label_name' => 'Name'])
```

**Here**,

1. `sorting` parameter default is false. `true` is sorting enabled, if don't need sorting just put `false` or just remove sorting parames.
2. `field_name` parameter is column in database table field, **name**.
3. `label_name` parameter is displayed inside anchor tags and print valueable field name. incase of `label_name` doe'st use automatically get column in database table field.

**what are field sorting declare the using your *Eloquent* model(s) inside function like below code**,

Use **FilterSortSearchable** trait inside your *Eloquent* model(s).

### *Eloquent* model

[](#eloquent-model)

```
use Devchithu\LaravelFilterSortingSearchable\Traits\FilterSortingSearchable;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, FilterSortingSearchable;
    ...
    ...

    /**
     * The table sorting order asc and desc.
     *
     * @var string
     */

    public $sorting = [
        'id',
        'name',
        'email',
        'created_at',
    ];

}
```

### Controller's `index()` method

[](#controllers-index-method)

```
public function index(Request $request)
{
    $users = User::sorting()->get();

    return view('user.index', ['users' => $users]);
}
```

\* Inline Filter
----------------

[](#-inline-filter)

***Blade table config***

There is a sorting similar same blade extension for you to use **@filterSort()**

```
 @filterSort(['filter' => true, 'field_name' => 'instance_type'])
```

**Custom field name filter**

```
@filterSort(['filter' => true,'field_name' => 'name', 'label_name' => 'Name'])
```

**what are field filterable declare the using your *Eloquent* model(s) inside function like below code**,

```
use Devchithu\LaravelFilterSortingSearchable\Traits\FilterSortingSearchable;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, FilterSortingSearchable;
    ...
    ...

    /**
     * The table filter order asc and desc.
     *
     * @var string
     */

     public $filterable = [
        'id',
        'name',
        'email'
    ];

}
```

### Controller's `index()` method

[](#controllers-index-method-1)

```
public function index(Request $request)
{
    $users = User::filterable()->get();

    return view('user.index', ['users' => $users]);
}
```

Sorting &amp; Filter
--------------------

[](#sorting--filter)

Incase, If you want sort and filter sametime using below Code,

```
 @filterSort(['sotring' => true, 'filter' => true, 'field_name' => 'status_type', 'label_name' => 'Status Type '])
```

**Here**,

1. `filter` parameter default is false. `true` is filter enabled, if don't need filter just put `false` or just remove filter parames.
2. `field_name` parameter is column in database table field, **name**.
3. `label_name` parameter is displayed inside anchor tags and print valueable field name. incase of `label_name` doe'st use automatically get column in database table field.

**UI - filter input field automatically generate**

1. filter is `true` default create input box type = 'text', if you want different input type like (selelect, radio, range) below code put the array params `'type' => 'text' // 'type' => 'select' or  radio, range`

Here, if you `select ` option using multiple option value data like `'multiple\_option' =&gt; \['All', 'active', 'in\_active'\]

```
 @filterSortSearchable(['sorting' => true, 'filter' => true, 'type' => 'select', 'field_name' => 'status', 'label_name' => 'Status', 'multiple_option' => ['All', 'active', 'in_active']])

```

**what are field sorting and filter declare the using your *Eloquent* model(s) inside function like below code**,

```
use Devchithu\LaravelFilterSortingSearchable\Traits\FilterSortingSearchable;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, FilterSortingSearchable;
    ...
    ...

    /**
     * The table sorting order asc and desc.
     *
     * @var string
     */

    public $sorting = [
        'id',
        'name',
        'email',
        'created_at',
    ];

    /**
     * The table filter.
     *
     * @var string
     */

     public $filterable = [
        'id',
        'name',
        'email'
    ];

}
```

### Controller's `index()` method

[](#controllers-index-method-2)

```
public function index(Request $request)
{
    $users = User::sorting()->filterable()->get();

    return view('user.index', ['users' => $users]);
}
```

### Controller's `index()` method with paginate()

[](#controllers-index-method-with-paginate)

```
public function index(Request $request)
{
    $users = User::sorting()->filterable()->paginate(20);

    return view('user.index', ['users' => $users]);
}
```

\*Searchable
------------

[](#searchable)

This searchable global area find the table data

**what are field searchable declare the using your *Eloquent* model(s) inside function like below code**,

```
use Devchithu\LaravelFilterSortingSearchable\Traits\FilterSortingSearchable;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, FilterSortingSearchable;
    ...
    ...

    /**
     * The table searchable.
     *
     * @var string
     */

     public $searchable = [
        'id',
        'name',
        'email'
    ];

}
```

There is a blade extension for you to use **@searchable()**

```
@searchable()
```

### Controller's `index()` method

[](#controllers-index-method-3)

```
public function index(Request $request)
{
    $users = User::searchable()->get();

    return view('user.index', ['users' => $users]);
}
```

### Controller's `index()` method

[](#controllers-index-method-4)

If you want filter, sorting, searchable declare the scope function

```
public function index(Request $request)
{
    $users = User::sorting()->filterable()->searchable()->get();

    return view('user.index', ['users' => $users]);
}
```

\*customized filter
===================

[](#customized-filter)

If you want filter some field customazed used here file

```
php artisan vendor:publish --tag=customFilterTrait

```

See app\\CustomFilter\\CustomFilterTrait.php (if you want any change update this code inside)

**what are the customized filter field don't declare (filterable) array. declare custom filterable the using your *Eloquent* model(s) inside function**,

```
use Devchithu\LaravelFilterSortingSearchable\Traits\FilterSortingSearchable;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, FilterSortingSearchable;
    ...
    ...

    /**
     * The table filter.
     *
     * @var string
     */

     public $customfilterable = [
            'name',
            'status',
    ];

}
```

\* Binding Params
-----------------

[](#-binding-params)

What are field sorting, searching and filterting below code Which place to you want binding parameters declare the **@bindingParams()**

```
@bindingParams()
```

Run finally,

```
php artisan op:cl

```

OR,

2. Bootstrap filter using Modal, Offcanvas Blade Extension
----------------------------------------------------------

[](#2-bootstrap-filter-using-modal-offcanvas-blade-extension-1)

Publish Js file
---------------

[](#publish-js-file-1)

then run publish cmd you must to publish only js file your want 'filter, sort, searchable' using the below script in blade.php file

```
php artisan vendor:publish --tag=filter-sorting-searchable-modal-offcanvas

```

See public/filter-sorting-searchable-modal-offcanvas.js (if you want any change update this code inside)

Must push that js file in blade, where-ever your want like (better than push that js file into main index blade.php):

```

```

OR,

```
@push('scripts')

@endpush

```

Sorting &amp; Filter
--------------------

[](#sorting--filter-1)

Incase, If you want sort and filter sametime using below Code,

```
 @filterSort(['sotring' => true, 'filter' => true, 'field_name' => 'status_type', 'label_name' => 'Status Type '])
```

Modal Offcanvas Filter
----------------------

[](#modal-offcanvas-filter)

Filter `Button` show below code in blade: Whereever you want filter button put the code **@filterBtn()**

***Default Offcanvas***

Here, Bootstrap5^ default offcanvas inside.

```
 @filterBtn()
```

***Change Custom name***

when, if you need button label name change parse the parameter like

```
  @filterBtn(['label' => 'custom-name'])
```

***Bootstrap5^ Offcanvas and Modal***

Default offcanvas don't need any params, if need to change modal window like code :

***Bootstrap5 Modal***

```
 @filterBtn(['viewport' => 'modal', 'label_name' => 'custom-name'])
```

**Here**

1. **viewport** is default `offcanvas` if change modal given in array inside
2. if **viewport\_direction** is `offcanvas` placement direction (like: `offcanvas-start, offcanvas-end, offcanvas-top, offcanvas-bottom`)
3. if **viewport\_direction** is `modal` placement modal-dialog-position (like: `modal-dialog-centered, modal-size-(xl)*`)

Run finally,

```
php artisan op:cl

```

***Don't declare at the sametime two type of js file, at time only one using js file***

(filter-sorting-searchable.js Or filter-sorting-searchable-modal-offcanvas.js)

Thank you .

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 65.7% 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 ~1 days

Total

10

Last Release

1058d ago

### Community

Maintainers

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

---

Top Contributors

[![chithresudev](https://avatars.githubusercontent.com/u/40000188?v=4)](https://github.com/chithresudev "chithresudev (23 commits)")[![chithresuganesan](https://avatars.githubusercontent.com/u/40829565?v=4)](https://github.com/chithresuganesan "chithresuganesan (12 commits)")

### Embed Badge

![Health badge](/badges/devchithu-laravel-filter-sorting-searchable/health.svg)

```
[![Health](https://phpackages.com/badges/devchithu-laravel-filter-sorting-searchable/health.svg)](https://phpackages.com/packages/devchithu-laravel-filter-sorting-searchable)
```

###  Alternatives

[ircmaxell/filterus

A library for filtering variables in PHP

44613.4k6](/packages/ircmaxell-filterus)[awesome-nova/dependent-filter

Dependent filters for Laravel Nova

26190.2k](/packages/awesome-nova-dependent-filter)

PHPackages © 2026

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