dinkbit / filterable
Make your eloquent models filterable with ease.
dev-master / 1.0.x-dev
2015-02-28 18:37 UTC
Requires
- php: >=5.4.0
- illuminate/support: ~4.0|~5.0
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-11-09 17:56:26 UTC
README
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();