Skip to content
Advertisement

Symfony : how to get all user posts related with oneToMany relation

I have two entity User and Booking which are related with oneToMany relationship, when a user ake a booking the user id is saved in the user_id column table of booking, I want in my controller to retrieve all the user’s booking !

JavaScript

JavaScript

JavaScript

when trying to get the connected user and call getBookings() method it doesn’t return any thing !

here what does $this->getUser return :

enter image description here

Advertisement

Answer

I found the solution, I just forgot to add fetch EAGER to the OneToMany relationship between User and Booking !

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement