Skip to content

Commit

Permalink
fix(UserFixtures): user projects persistence
Browse files Browse the repository at this point in the history
see: #20, #30
  • Loading branch information
n3wborn committed Nov 1, 2023
1 parent 57809b9 commit 243e1d3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/DataFixtures/UserFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\DataFixtures;

use App\Entity\Project;
use App\Entity\User;
use App\Repository\ProjectRepository;
use Doctrine\Bundle\FixturesBundle\Fixture;
Expand All @@ -27,9 +28,12 @@ public function load(ObjectManager $manager): void
$user = $this->createUser($i);

for ($j = 1; $j <= $count; ++$j) {
/** @var Project $randProject */
$randProject = $this->projectRepository->findOneByName('project-'.rand(1, ProjectFixtures::QUANTITY));
$user->addProject($randProject);
$randProject->setUserProject($user);
$manager->persist($user);
$manager->persist($randProject);
}
}

Expand Down

0 comments on commit 243e1d3

Please sign in to comment.