0
votes

I have some entities with many to one relations

User <--> Department <--> Office <--> Organisation

Also I have another entity called Booking, which is related to User

I need to make a query to only get those Bookings related to a specific Organisation

$rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder
    ->leftJoin(sprintf('%s.user', $rootAlias), 'u')
    ->leftJoin('u.department', 'd')
    ->leftJoin('d.office', 'o')
    ->andWhere('o.organisation = :organisation')
    ->setParameter('organisation', $organisation);

this does not work. How can I properly use leftJoin in QueryBuilder when multiple tables are involved?

1

1 Answers

0
votes