New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

bzarzuela/modelfilter

Utility Class for Laravel 5 to assist in easily filtering paginated results.
1,653 5
Install
composer require bzarzuela/modelfilter
Latest Version:v0.1.4
PHP:>=5.5.0
License:MIT
Last Updated:Jul 16, 2017
Links: GitHub  ·  Packagist
Maintainer: bzarzuela

Model Filter

Utility Class for Laravel 5 to assist in easily filtering paginated results

Installation

composer require bzarzuela/modelfilter

Usage

Use in actions that show the list of models. In this example, it's the index action in the TicketsController.

public function index()
{
    $model_filter = new ModelFilter('tickets');

    $model_filter->setRules([
        'id' => ['primary'],
        'concern_types' => ['in', 'concern_type_id'],
        'created_from' => ['from', 'created_at'],
        'created_to' => ['to', 'created_at'],
    ]);

    $tickets = $model_filter->filter(Ticket::query())->paginate(30);

    $filters = $model_filter->getFormData();

    return view('tickets.index', compact('tickets', 'filters'));
}

The $filters variable passed to the view allows for the form to render the previously specified filters.

Related Packages

mjarestad/filtry

Filter and sanitize input data in Laravel 4/5 or as a standalone package.

230,344 13
daveismyname/laravel-filters

Save and reuse query string based filters

63,590 9
coderscantina/laravel-filter

A filter object for Laravel/Eloquent models based on laracasts approach.

9,460 2
webbingbrasil/filament-advancedfilter

Advanced filter component for filament admin.

163,201 147
jerome/filterable

Streamline dynamic Eloquent query filtering with seamless API request integratio...

52,676 194

Version History

Version Released PHP License
v0.1.4 >=5.5.0 MIT
v0.1.3 >=5.5.0 MIT
v0.1.2 >=5.5.0 MIT
v0.1.1 >=5.5.0 MIT
v0.1 >=5.5.0 MIT