I have this issue and I don't know really why...
The Repository :
/**
* @return Creations[]
*/
public function displayOne(): array
{
return $this->createQueryBuilder('c')
->andWhere('c.category.id = 1')
->setMaxResults(3)
->getQuery()
->getResult();
// returns an array of Product objects
return $query->getResult();
}
}
The Entity :
/**
* @ORM\ManyToOne(targetEntity=Category::class, inversedBy="creations")
* @ORM\JoinColumn(nullable=false)
*/
private $category;
The controller function :
public function index(): Response
{
$repository = $this->entityManager->getRepository(Creations::class);
$creations = $repository->findAll();
$categories = $this->entityManager->getRepository(Category::class)->findAll();
return $this->render('creations/index.html.twig', [
'creations' => $repository->displayOne(),
'categories' => $categories
]);
}
Also when I dd($creations), I got the good "link" thecreation -> category -> id -> 1 for example
Thanks for your help !