diff --git a/src/DataFixtures/ProjectFixtures.php b/src/DataFixtures/ProjectFixtures.php index 5c83920..1db8540 100644 --- a/src/DataFixtures/ProjectFixtures.php +++ b/src/DataFixtures/ProjectFixtures.php @@ -20,13 +20,14 @@ public function __construct( public function load(ObjectManager $manager): void { for ($i = 1; $i <= self::QUANTITY; ++$i) { - $count = rand(1, 5); $project = $this->createProject($i); - $manager->persist($project); + $count = rand(1, 5); for ($j = 1; $j <= $count; ++$j) { $randCategory = $this->categoryRepository->findOneBy(['name' => 'category-'.rand(1, CategoryFixtures::CATEGORY_QUANTITY)]); $randCategory->addProject($project); + $project->addCategory($randCategory); + $manager->persist($project); $manager->persist($randCategory); } }