ikucheriavenko
1/15/2019 - 7:33 PM

QB filter collection

     $pack2 = $qb
            ->select('prem', 'purc')
            ->from(PremiumPackage::class, 'prem')
            ->join('prem.purchases', 'purc')
            ->andWhere($qb->expr()->eq('purc.userId', 2356))
            ->andWhere("purc.expiredAt > '".$now->format("Y-m-d H:i:s")."'")
            ->andWhere($qb->expr()->in('purc.status', PurchaseStatus::getActiveStatusesList()))
            ->andWhere($qb->expr()->eq('prem.enabled', true))
            ->andWhere($qb->expr()->gte('prem.weight', 0))
            ->addCriteria(Criteria::create()
                              ->andWhere(Criteria::expr()->in('purc.status', PurchaseStatus::getActiveStatusesList()))
                              )
            ->getQuery()
            ->getResult()[0];