Bonjour,
je recupère les données d'un "participant" qui a une relation OneToMany avec "coursses" avec la requet suivante.
ici mon ParticipantRepository.php qui me permet d'extrait les données de ma BD
/**
* Récupère les participants en lien avec la recherche
* @return Participant[]
*/
public function findSearch2(ParticipantSearchData $search): array
{
$query = $this->createQueryBuilder('p')
->select('p', 'c')
->join('p.courses', 'c');
if (!empty($search->p)) {
$query = $query
->andWhere('p.id = :p')
->orderBy('c.id', 'DESC')
->setMaxResults(1)
->setParameter('p', $search->p);
}
return $query->getQuery()->getResult();
}
ici mon controller
if (!empty($participantsSearchForm->isSubmitted())) {
$participantSearch = $participantsRepo->findSearch2($data);
} else {
$participantSearch = null ;
}
dump($participantSearch);
return $this->render('participant/index.html.twig', [
'participantSearchForm' => $participantSearchForm->createView(),
'participantForm' => $participantForm->createView(),
'participantsSearch' => $participantSearch,
'editMode' => $participants->getId() !== null
]);
}
ici les infos de mon dump($participantSearch);
array:1 [▼
0 => App\Entity\Participant {#1502 ▼
-id: 10
-names: "Mathias Keebler"
-contact: 651286626
-language: "Anglais"
-type: "Jeunes intensif"
-slug: "mathias-keebler"
-regDate: DateTime @1633867465 {#1501 ▶}
-courses: Doctrine\ORM\PersistentCollection {#1454 ▼
-snapshot: array:1 [ …1]
-owner: App\Entity\Participant {#1502}
-association: array:15 [ …15]
-em: Doctrine\ORM\EntityManager {#332 …11}
-backRefFieldName: "participants"
-typeClass: Doctrine\ORM\Mapping\ClassMetadata {#1397 …}
-isDirty: false
#collection: Doctrine\Common\Collections\ArrayCollection {#1452 ▼
-elements: array:1 [▼
0 => App\Entity\Course {#1337 ▼
-id: 727
-level: "Avancé"
-module: "A"
-moduleNum: 4
-classDays: " Le Mercredi et Vendredi"
-classTimes: "14H - 16H"
-classRoom: "E"
-libraryDay: "vendredi"
-period: "Term 4"
-payType: "Totalité"
-payDescription: "A payer les frais d'inscription en totalité"
-payReceived: 25000
-regDate: DateTime @1615658277 {#1150 ▶}
-participants: App\Entity\Participant {#1502}
-reports: null
}
]
}
#initialized: true
}
}
]
Ce que je veux
je veux afficher en vu twig le "names" du participant sur App\Entity\Participant et les elements de courses qui se trouvent sur App\Entity\Course .
Merci d'avance pour ceux qui prendront le temps de me repondre.