New

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

maksa988/laravel-filters

Filters for Laravel
5,408 3

Larablocks Analysis

maksa988/laravel-filters works with Laravel 5 to 8 (latest release v0.3, Jan 26, 2021), all past end of life (the last on Jan 24, 2023): no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 5 to 8, past end of life since Jan 24, 2023
  • No release in the last 12 months (last: Jan 26, 2021)
  • 0 downloads a month (needs 10,000)
  • 3 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Jan 26, 2021.
  • No releases in the last 12 months.
  • First released: Aug 27, 2019.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 28, 2026.

Install
composer require maksa988/laravel-filters
Latest Version:v0.3
PHP:>=5.6.4
Laravel:5 – 8
License:MIT
Last Updated:Jan 26, 2021
Links: GitHub  ·  Packagist
Maintainer: maksa988

Laravel Filters

Filter models for Laravel.

PHP >= 5.6.4, Laravel >= 5.3

Installation

Filters for Laravel is installed via Composer. For most uses, you will need to require maksa988/laravel-filters and an individual gateway:

composer require maksa988/laravel-filters

Usage

First you need to create a filter, you can do this using the artisan command php artisan make:filter PostFilter.

After that the App\Filters directory will be created and the PostFilter filter will be created there.

<?php

namespace App\Filters;

use Maksa988\LaravelFilters\Filters;

class PostFilter extends Filters
{
    /**
     * Available filters
     *
     * @var array
     */
    protected $filters = [
        'title',
    ];

    /**
     * @param string $value
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function title($value)
    {
        return $this->builder->where('title', $value);
    }
}

In the filter class, create methods whose names you must specify in the $filters array. The method will receive the value that will be accepted from the request.

Elequent builder is available in the class to compile a query that will be called when filtering data.

/**
 * Display a listing of the resource.
 *
 * @param Post $post
 * @param PostFilter $filter
 * @return \Illuminate\View\View
 */
public function index(Post $post, PostFilter $filter)
{
    $list = $post->filter($filter)->paginate(20);

    return $this->view(compact('list'));
}

You can use the filter in the model by simply calling the scope filter, passing the class with the filter there.

In order for scope to be available in the model, you need to connect trait Maksa988\LaravelFilters\Traits\HasFilters:

class Post extends Model
{
    use HasFilters;
}

To filter data by the title filter in the address, just pass a field with that name, for example, this can be done using GET:

http://example.com/posts?title=Post%20title

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please send me an email at maksa988ua@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

caue-santos/laravel-request-filters

A laravel request filters

29,097 2
altra/context

Library to filter HTTP request responses by context.

15,036 0
blessing/filter

Filters API for designing plugin system.

5,463 0
laravel-liberu/filters

Filters dependency for Laravel Liberu

3,419 0
emargareten/eloquent-filters

Easily add filters to your eloquent models using simple arrays

3,116 6

Version History

Version Released PHP Laravel License
v0.3 >=5.6.4 >=5.3 MIT
v0.2 >=5.6.4 >=5.3 MIT
v0.1 >=5.6.4 ^5.3 MIT