Symfony 5 – Call to a member function function() on array

So i’m trying to fetch only my creations when the category_id = 1.

   /**
     * @return Creations[] Returns an array of Creations objects
     */

    public function displayOne()
    {
        return $this->createQueryBuilder('c')
            ->andWhere('c.category_id = 1')
            ->setMaxResults(3)
            ->getQuery()
            ->getResult()
            ;
    }

But when I want to Fetch it I have this error : Call to a member function display() on array

Here is what i put in my CreationsController

        $repository = $this->entityManager->getRepository(Creations::class);
        $creations = $repository->findAll();


        $categories = $this->entityManager->getRepository(Category::class)->findAll();

        return $this->render('creations/index.html.twig', [

            'creations' => $creations->display(),
            'categories' => $categories

        ]);
    }

Thanks for people who will help me. Don’t hesitate to ask more informations

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *