PHP code example of abelaguiar / filter-laravel

1. Go to this page and download the library: Download abelaguiar/filter-laravel 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/ */

    

abelaguiar / filter-laravel example snippets


use App\Filters\Fields\TitleField;
use AbelAguiar\Filter\AbstractFilter;

class PostClass extends AbstractFilter
{
    protected $filters = [
        'title' => TitleField::class
    ];
}

class TitleField
{
    public function filter($builder, $value)
    {
        return $builder->where('title', $value);
    }
}

use AbelAguiar\Filter\RequestFilter;

class Post
{
    use RequestFilter;
...

protected static $filter = 'App\Filters\PostFilter';
...

Post::filter($request)->get()
bash
php artisan filter:model <Model>
bash
php artisan filter:field <Name>