PHP code example of indexzer0 / eloquent-filtering
1. Go to this page and download the library: Download indexzer0/eloquent-filtering library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
indexzer0 / eloquent-filtering example snippets
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();
bash
php artisan eloquent-filtering:install