diff --git a/src/Service/League/createLeague/HandleCreateLeague.php b/src/Service/League/createLeague/HandleCreateLeague.php index 0f49a1c9..18aa9835 100644 --- a/src/Service/League/createLeague/HandleCreateLeague.php +++ b/src/Service/League/createLeague/HandleCreateLeague.php @@ -44,10 +44,10 @@ class HandleCreateLeague $leagueDto->validate(); $leagueEntity = $this->leagueFactory::create($leagueDto); $leagueEntity->setActive(true); - $this->assignPresidentRole($leagueEntity->getId(), $userEntity); $this->entityManager->persist($leagueEntity); $this->entityManager->flush(); + $this->assignPresidentRole($leagueEntity->getId(), $userEntity); $leagueDto->id = $leagueEntity->getId(); $leagueDto->createdAt = $leagueEntity->getCreatedAt(); @@ -66,5 +66,6 @@ class HandleCreateLeague $leaguePresidentRole->setEntityId($leagueId); $leaguePresidentRole->setUser($userEntity); $this->entityManager->persist($leaguePresidentRole); + $this->entityManager->flush(); } } \ No newline at end of file