PHP code example of bahram / bfilters

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

    

bahram / bfilters example snippets


public function index(YourModelFilter $filters): Response
{
    [$entries, $count, $sum] = YourModel::filter($filters);
    return ($entries->get());
}

public function rules()
{
    return [
        'id' => 'int|


class MessageFilter extends Filter
{
    public function __construct(Request $request)
    {
        $this->relations = [
            "packages" => [
                "numbers" => function ($query, $filter) {
                    $query->whereRaw("'{$filter->value}' {$filter->op} ANY(numbers)");
                },
            ],
            "line" => [
                "line_number" => "number",
            ],
        ];

        //$this->sumField = null;
        $this->validWiths = ["packages"];

        parent::__construct($request);
    }
}


public function Index(UserFilter $filters)
    {
        $filters->removeFilter('first_name')->removePagination();
    }

$filters->setPage(
                    [
                        "limit" => 20,
                        "offset"=> 100
                    ]
                  );