Skip to content

dinkbit/filterable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Filterable Eloquent Models

Build Status StyleCI

Setup

use Dinkbit\Filterable\FiterableTrait;

class Post extends Eloquent
{
    use FilterableTrait;

    /**
     * Enabled filterable scopes.
     *
     * @var string
     */
    protected $filterable = ['price', 'quantity'];

    public function scopePrice($query, $param)
    {
        return $query->where('price', $param);
    }

    public function scopeQuantity($query, $param)
    {
        return $query->where('item_quantity', $param);
    }
}

Usage

$posts = Post::filter(['quantity' => 10, 'price' => '100'])->get();

About

Make your eloquent models filterable with ease.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages