Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function findAllWithPhoto()
- {
- return $qb = $this->createQueryBuilder('p')
- ->join('App\Entity\Category', 'c', 'WITH', 'p.category = c.id')
- ->select([
- 'p.id',
- 'p.name',
- 'p.price',
- 'CASE WHEN p.preview IS NULL THEN \'no-image-available.png\' ELSE concat(c.photoPrefix, \'/\', p.preview) END AS preview'
- ])->getQuery()->getResult();
- }
- public function findPhotoByProduct(Product $product)
- {
- return $qb = $this->createQueryBuilder('p')
- ->join('App\Entity\Product', 'prod', 'WITH', 'p.product = prod.id')
- ->join('App\Entity\Category', 'c', 'WITH', 'prod.category = c.id')
- ->select([
- 'p.id',
- 'CONCAT(c.photoPrefix, \'/\', p.fileNameSmall) AS fileNameSmall',
- 'CONCAT(c.photoPrefix, \'/\', p.fileNameBig) AS fileNameBig'
- ])
- ->andWhere('p.product = :id')
- ->setParameter('id', $product->getId())
- ->getQuery()->getResult();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement