79537236

Date: 2025-03-26 20:46:21
Score: 2
Natty:
Report link

Edited code and got it working. Thank you, @nico_haase!

$instituteEntities = [];

        for ($i = 0; $i < count($instituteList); $i++) {
            $institute = new Institute();
            $institute->setName($instituteList[$i]);
            $instituteEntities[] = $institute;
            $manager->persist($institute);
        }

        for ($i = 0; $i < count($departmentList); $i++) {
            $department = new Department();
            $department->setName($departmentList[$i]);
            $department->setInstitute($instituteEntities[rand(0, count($instituteEntities) - 1)]);
            $manager->persist($department);
        }
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @nico_haase
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Славик Михненко