93 search results for andWhere

47 lines | src/Repository/QuestionRepository.php
// ... lines 1 - 14
class QuestionRepository extends ServiceEntityRepository
{
// ... lines 17 - 24
public function findAllAskedOrderedByNewest()
{
return $this->createQueryBuilder('q')
->andWhere('q.askedAt IS NOT NULL')
// ... line 29
->getQuery()
->getResult()
;
}
// ... lines 34 - 45
}
See Code Block in Script
87 lines | src/Repository/UserRepository.php
// ... lines 1 - 14
class UserRepository extends ServiceEntityRepository
{
// ... lines 17 - 46
/**
* @return User[]
*/
public function findAllSubscribedToNewsletter(): array
{
return $this->createQueryBuilder('u')
->andWhere('u.subscribeToNewsletter = 1')
->getQuery()
->getResult();
}
// ... lines 57 - 85
}
See Code Block in Script
87 lines | src/Repository/UserRepository.php
// ... lines 1 - 14
class UserRepository extends ServiceEntityRepository
{
// ... lines 17 - 49
public function findAllSubscribedToNewsletter(): array
{
return $this->createQueryBuilder('u')
->andWhere('u.subscribeToNewsletter = 1')
->getQuery()
->getResult();
}
// ... lines 57 - 85
}
See Code Block in Script
217 lines | src/Entity/Article.php
// ... lines 1 - 6
use Doctrine\Common\Collections\Criteria;
// ... lines 8 - 14
class Article
{
// ... lines 17 - 183
public function getNonDeletedComments(): Collection
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('isDeleted', false))
// ... lines 188 - 191
}
// ... lines 193 - 215
}
See Code Block in Script
224 lines | src/AppBundle/Entity/Genus.php
// ... lines 1 - 5
use Doctrine\Common\Collections\Criteria;
// ... lines 7 - 15
class Genus
{
// ... lines 18 - 214
public function getExpertScientists()
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->gt('yearsStudied', 20))
// ... lines 219 - 221
}
}
See Code Block in Script
// ... lines 1 - 14
public function countNumberPrintedForCategory(Category $category)
{
return $this->createQueryBuilder('fc')
->andWhere('fc.category = :category')
->setParameter('category', $category)
->select('SUM(fc.numberPrinted) as fortunesPrinted')
// ... lines 21 - 22
}
// ... lines 24 - 26
See Code Block in Script
// ... lines 1 - 23
public function search($term)
{
return $this->createQueryBuilder('cat')
->andWhere('cat.name LIKE :searchTerm')
->setParameter('searchTerm', '%'.$term.'%')
->getQuery()
->execute();
}
// ... lines 32 - 33
See Code Block in Script
58 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 15
class ArticleRepository extends ServiceEntityRepository
{
// ... lines 18 - 46
private function addIsPublishedQueryBuilder(QueryBuilder $qb = null)
{
return $this->getOrCreateQueryBuilder($qb)
->andWhere('a.publishedAt IS NOT NULL');
}
// ... lines 52 - 56
}
See Code Block in Script
47 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 14
class ArticleRepository extends ServiceEntityRepository
{
// ... lines 17 - 24
public function findAllPublishedOrderedByNewest()
{
return $this->createQueryBuilder('a')
->andWhere('a.publishedAt IS NOT NULL')
->orderBy('a.publishedAt', 'DESC')
// ... lines 30 - 31
;
}
// ... lines 34 - 45
}
See Code Block in Script
47 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 14
class ArticleRepository extends ServiceEntityRepository
{
// ... lines 17 - 24
public function findAllPublishedOrderedByNewest()
{
return $this->createQueryBuilder('a')
->andWhere('a.publishedAt IS NOT NULL')
->orderBy('a.publishedAt', 'DESC')
// ... lines 30 - 31
;
}
// ... lines 34 - 45
}
See Code Block in Script
49 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 14
class ArticleRepository extends ServiceEntityRepository
{
// ... lines 17 - 24
public function findAllPublishedOrderedByNewest()
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
// ... lines 30 - 33
;
}
// ... lines 36 - 47
}
See Code Block in Script
// ... lines 1 - 7
class BattleRepository extends EntityRepository
{
public function createQueryBuilderForProgrammer(Programmer $programmer)
{
return $this->createQueryBuilder('battle')
->andWhere('battle.programmer = :programmer')
->setParameter('programmer', $programmer);
}
}
See Code Block in Script
93 lines | src/Repository/CategoryRepository.php
// ... lines 1 - 40
public function search(string $term): array
{
return $this->createQueryBuilder('category')
->andWhere('category.name LIKE :searchTerm OR category.iconKey LIKE :searchTerm')
// ... lines 45 - 47
}
// ... lines 49 - 93
See Code Block in Script
93 lines | src/Repository/CategoryRepository.php
// ... lines 1 - 40
public function search(string $term): array
{
return $this->createQueryBuilder('category')
->andWhere('category.name LIKE :searchTerm')
->setParameter('searchTerm', '%'.$term.'%')
// ... lines 46 - 47
}
// ... lines 49 - 93
See Code Block in Script
93 lines | src/Repository/CategoryRepository.php
// ... lines 1 - 40
public function search(string $term): array
{
return $this->createQueryBuilder('category')
->andWhere('category.name = :searchTerm')
->setParameter('searchTerm', $term)
->getQuery()
->getResult();
}
// ... lines 49 - 93
See Code Block in Script
// ... lines 1 - 11
class CheeseListingIsPublishedExtension implements QueryCollectionExtensionInterface, QueryItemExtensionInterface
{
private $security;
public function __construct(Security $security)
{
$this->security = $security;
}
public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null)
{
$this->addWhere($queryBuilder, $resourceClass);
}
public function applyToItem(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, array $identifiers, string $operationName = null, array $context = [])
{
$this->addWhere($queryBuilder, $resourceClass);
}
private function addWhere(QueryBuilder $queryBuilder, string $resourceClass): void
{
if ($resourceClass !== CheeseListing::class) {
return;
}
if ($this->security->isGranted('ROLE_ADMIN')) {
return;
}
$rootAlias = $queryBuilder->getRootAliases()[0];
if (!$this->security->getUser()) {
$queryBuilder->andWhere(sprintf('%s.isPublished = :isPublished', $rootAlias))
->setParameter('isPublished', true);
} else {
$queryBuilder->andWhere(sprintf('
%s.isPublished = :isPublished
OR %s.owner = :owner',
$rootAlias, $rootAlias
))
->setParameter('isPublished', true)
->setParameter('owner', $this->security->getUser());
}
}
}
See Code Block in Script
29 lines | src/Repository/AnswerRepository.php
// ... lines 1 - 6
use Doctrine\Common\Collections\Criteria;
// ... lines 8 - 15
class AnswerRepository extends ServiceEntityRepository
{
// ... lines 18 - 22
public static function createApprovedCriteria(): Criteria
{
return Criteria::create()
->andWhere(Criteria::expr()->eq('status', Answer::STATUS_APPROVED));
}
}
See Code Block in Script
188 lines | src/Entity/Question.php
// ... lines 1 - 7
use Doctrine\Common\Collections\Criteria;
// ... lines 9 - 15
class Question
{
// ... lines 18 - 157
public function getApprovedAnswers(): Collection
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('status', Answer::STATUS_APPROVED));
return $this->answers->matching($criteria);
}
// ... lines 165 - 186
}
See Code Block in Script
188 lines | src/Entity/Question.php
// ... lines 1 - 7
use Doctrine\Common\Collections\Criteria;
// ... lines 9 - 15
class Question
{
// ... lines 18 - 157
public function getApprovedAnswers(): Collection
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('status', Answer::STATUS_APPROVED));
// ... lines 162 - 163
}
// ... lines 165 - 186
}
See Code Block in Script
// ... lines 1 - 5
use Doctrine\Common\Collections\Criteria;
// ... lines 7 - 8
class GenusRepository extends EntityRepository
{
// ... lines 11 - 26
static public function createExpertCriteria()
{
return Criteria::create()
->andWhere(Criteria::expr()->gt('yearsStudied', 20))
->orderBy(['yearsStudied' => 'DESC']);
}
}
See Code Block in Script