Skip to main content
Back to packages
225 GitHub stars

IndexZer0/eloquent-filtering

View on GitHub

Description

Easily filter eloquent models using arrays - great for filtering from http requests.

class Product extends Model implements IsFilterable
{
use Filterable;
 
public function allowedFilters(): AllowedFilterList
{
return Filter::only(
Filter::field('name', [FilterType::EQUAL]),
);
}
}
 
$products = Product::filter([
[
'target' => 'name',
'type' => '$eq',
'value' => 'TV'
]
])->get();

Recent Courses on Laravel Daily