Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
trash
/
vhost_www.bachtale.com_1719306535
/
htdocs
/
src
/
Repository
/
/srv/data/trash/vhost_www.bachtale.com_1719306535/htdocs/src/Repository/ProductRepository.php
<?php namespace App\Repository; use App\Entity\Product; use Doctrine\ORM\Query; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; /** * @method Product|null find($id, $lockMode = null, $lockVersion = null) * @method Product|null findOneBy(array $criteria, array $orderBy = null) * @method Product[] findAll() * @method Product[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class ProductRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Product::class); } public function findByFilter(array $search) { $query = $this->findVisibleQuery(); $query = $query ->leftJoin('p.metals', 'm'); if ($search) { $collectionJewelleryOrX = $query->expr()->orX(); $categoryOrX = $query->expr()->orX(); $metalOrX = $query->expr()->orX(); foreach ($search as $data) { if (null !== $data) { if($data['type'] == 'collectionJewellery'){ $collectionJewelleryOrX ->add($query->expr()->eq('p.collectionJewellery', ':collectionJewellery_'.$data['id'])); $query = $query ->setParameter('collectionJewellery_'.$data['id'], $data['id']); } if($data['type'] == 'category'){ $categoryOrX ->add($query->expr()->eq('p.category', ':category_'.$data['id'])); $query = $query ->setParameter('category_'.$data['id'], $data['id']); } if($data['type'] == 'metals'){ $metalOrX ->add($query->expr()->eq('m', ':matal_'.$data['id'])); $query = $query ->setParameter('matal_'.$data['id'], $data['id']); } } } $query = $query ->andWhere($collectionJewelleryOrX) ->andWhere($categoryOrX) ->andWhere($metalOrX); } $query = $query ->orderBy('p.updatedAt', 'DESC'); //var_dump($query->getQuery()->getSql()); return $query->getQuery()->getResult(); } public function findVisibleQuery() { return $this->createQueryBuilder('p') ->where('p.isActive = 1'); } // /** // * @return Product[] Returns an array of Product objects // */ /* public function findByExampleField($value) { return $this->createQueryBuilder('p') ->andWhere('p.exampleField = :val') ->setParameter('val', $value) ->orderBy('p.id', 'ASC') ->setMaxResults(10) ->getQuery() ->getResult() ; } */ /* public function findOneBySomeField($value): ?Product { return $this->createQueryBuilder('p') ->andWhere('p.exampleField = :val') ->setParameter('val', $value) ->getQuery() ->getOneOrNullResult() ; } */ }