LaravelPackages.net
Acme Inc.
Toggle sidebar
fugazi-code/laravel-eloquent-filter

A custom filter for your Eloquent Builder

5
0
1.0.2
About fugazi-code/laravel-eloquent-filter

fugazi-code/laravel-eloquent-filter is a Laravel package for a custom filter for your eloquent builder. It currently has 0 GitHub stars and 5 downloads on Packagist (latest version 1.0.2). Install it with composer require fugazi-code/laravel-eloquent-filter. Discover more Laravel packages by fugazi-code or browse all Laravel packages to compare alternatives.

Last updated

Filter

Latest Version on Packagist Total Downloads

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require fugazi-code/laravel-eloquent-filter

Usage

Change log

Please see the changelog for more information on what has changed recently.

Install

$ php artisan make:filter UserFilter

Filter Class

<?php

namespace App\Http\Controllers\Filters;

use FugaziCode\Filter\Filter;

class UserFilter extends Filter
{
    public function email($value)
    {
        $this->query->where('email', 'like', "%$value%");
    }

    public function permanent($value)
    {
        $this->query->whereHas('address', function($query) use ($value) {
            $query->where('permanent', 'like', "%$value%");
        });
    }
}

Eloquent Implementation

Route::get('/', function () {
    return User::query()->with(['address'])->filter(new UserFilter)->get();
});

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

Comments