PHP code example of san4io / eloquent-filter
1. Go to this page and download the library: Download san4io/eloquent-filter 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/ */
san4io / eloquent-filter example snippets
class Event extends Model
{
use Filterable;
protected $fillable = [
'country_id',
'title',
];
protected $filterable = [
'country_id' => WhereFilter::class,
'title' => LikeFilter::class,
'created_at' => BetweenFilter::class
];
}
public function index(Request $request): JsonResponse
{
$events = Event::filter($request->all())->paginate(); // or get(), first() or whatever
return response()->json($events);
}