Skip to content

Instantly share code, notes, and snippets.

@pchelk1n
Created September 8, 2017 09:45
Show Gist options
  • Save pchelk1n/27973dd2aa78dd27eb9ebb503c32e76f to your computer and use it in GitHub Desktop.
Save pchelk1n/27973dd2aa78dd27eb9ebb503c32e76f to your computer and use it in GitHub Desktop.
<?php
namespace AppBundle\Entity\Spec;
use Doctrine\ORM\QueryBuilder;
use Happyr\DoctrineSpecification\Query\QueryModifier;
/**
* Class Select
*/
class Select implements QueryModifier
{
/**
* @var string field
*/
protected $alias;
/**
* @param string $alias
*/
public function __construct($alias)
{
$this->alias = $alias;
}
/**
* @param QueryBuilder $qb
* @param string $dqlAlias
*/
public function modify(QueryBuilder $qb, $dqlAlias)
{
$qb->addSelect($this->alias);
}
}
@pchelk1n
Copy link
Author

pchelk1n commented Sep 8, 2017

Use

return Spec::andX(
    new Select('MIN(variants.price) AS price')
);

variants - alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment