PHP code example of labrodev / laravel-filter-components

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

    

labrodev / laravel-filter-components example snippets


use Illuminate\Http\Request;
use Labrodev\Filters\QueryBuilder\DateRangeFilter;
use Labrodev\Filters\QueryBuilder\WhereInFilter;
use Labrodev\Filters\QueryBuilder\IsNotNullFilter;
use Spatie\QueryBuilder\AllowedFilter;
use Spatie\QueryBuilder\QueryBuilder;

class YourQuery extends QueryBuilder
{
    public function __construct(Request $request)
    {
        $query = YourModel::query();

        parent::__construct($query, $request);

        //DateRangeFilter
        $this->allowedFilters([
            AllowedFilter::custom('filter_name', new DateRangeFilter(), 'table_column') 
        ]);

        //DateRangeFilter
        $this->allowedFilters([
            AllowedFilter::custom('filter_name', new WhereInFilter(), 'table_column') 
        ]);

        //IsNotNullFilter
        $this->allowedFilters([
            AllowedFilter::custom('filter_name', new IsNotNullFilter(), 'table_column') 
        ]);
    }
}
bash
php artisan vendor:publish --tag=filter-components-views
bash
php artisan vendor:publish --tag=filter-components-components
bash
composer analyse