This commit is contained in:
Sergio Álvarez 2022-05-22 18:36:49 +02:00
parent 86205bbdba
commit 1a6281855f
No known key found for this signature in database
GPG Key ID: BD711A37FE7DD77E
1 changed files with 22 additions and 2 deletions

View File

@ -3,7 +3,11 @@
namespace App\DataFixtures; namespace App\DataFixtures;
use App\Entity\Employee1; use App\Entity\Employee1;
use App\Entity\Employee2;
use App\Entity\Employee3;
use App\Entity\Toothbrush1; use App\Entity\Toothbrush1;
use App\Entity\Toothbrush2;
use App\Entity\Toothbrush3;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -12,13 +16,29 @@ class InheritanceFixtures extends Fixture
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
$e1 = new Employee1(); $e1 = new Employee1();
$e1->setJob('peon')->setName('pepito')->setAge(20)->setToothbrush((new Toothbrush1())->setBrand('colgate')); $e1->setJob('peon1')->setName('pepito1')->setAge(20)->setToothbrush((new Toothbrush1())->setBrand('colgate1'));
$manager->persist($e1); $manager->persist($e1);
$e1 = new Employee1(); $e1 = new Employee1();
$e1->setJob('jefe')->setName('benganito')->setAge(30)->setToothbrush((new Toothbrush1())->setBrand('signal')); $e1->setJob('jefe1')->setName('benganito1')->setAge(30)->setToothbrush((new Toothbrush1())->setBrand('signal1'));
$manager->persist($e1); $manager->persist($e1);
$e2 = new Employee2();
$e2->setJob('peon2')->setName('pepito2')->setAge(20)->setToothbrush((new Toothbrush2())->setBrand('colgate2'));
$manager->persist($e2);
$e2 = new Employee2();
$e2->setJob('jefe2')->setName('benganito2')->setAge(30)->setToothbrush((new Toothbrush2())->setBrand('signal2'));
$manager->persist($e2);
$e3 = new Employee3();
$e3->setJob('peon3')->setName('pepito3')->setAge(20)->setToothbrush((new Toothbrush3())->setBrand('colgate3'));
$manager->persist($e3);
$e3 = new Employee3();
$e3->setJob('jefe3')->setName('benganito3')->setAge(30)->setToothbrush((new Toothbrush3())->setBrand('signal3'));
$manager->persist($e3);
$manager->flush(); $manager->flush();
} }
} }