Start your All-Access Pass to unlock this challenge
Buy Access Login

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?

Select your answer
Skip challenges and go to theNext Chapter

Turn Challenges Off?

All further challenges will be skipped automatically.
You can re-enable challenges at any time on this page or from your account page.