Start your All-Access Pass to unlock this challenge
Challenge 1 / 1
On the "Category" page, I've added a search box that will allow my users to search for
products that are in that category. Here's the query I built for this in ProductRepository:
public function searchCategory(Category $category, string $search): array
{
return $this->createQueryBuilder('product')
->andWhere('product.category = :category')
->andWhere('product.name LIKE :term')
->orWhere('product.description LIKE :term')
->setParameter('category', $category)
->setParameter('term', '%'.$search.'%')
->getQuery()
->getResult();
}
Is this correct?
Skip challenges and go to theNext Chapter