PHP code example of queo / doctrine-filter

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

    

queo / doctrine-filter example snippets


use Queo\DoctrineFilter\FilterBuilder;
use Queo\DoctrineFilter\FilterInterface;

class MyFilter implements FilterInterface
{
    public function buildFilter(FilterBuilder $builder)
    {
        // ...
    }
}

public function buildFilter(FilterBuilder $builder)
{
    $builder
        ->add('category', EqualFilterType::class)
        ->add('price_max', LessThanEqualFilterType::class)
        ->orderBy('price', 'DESC);
}

use Doctrine\ORM\EntityRepository;
use Queo\DoctrineFilter\Traits\EntityFilterTrait;

class MyRepository extends EntityRepository
{
    use EntityFilterTrait;
}

use Queo\DoctrineFilter\Type\BetweenFilterType;

$builder
	->add('price', BetweenFilterType::class, [
		'lower_bound_suffix' => 'from',
		'upper_bound_suffix' => 'to',
	]);
	
//...

$em->getRepository(MyEntity::class)->filter(new MyFilter(), [
	'price_from' => 40,
	'price_to' => 80
]);