Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\DataFixtures;
- use App\Entity\Novel;
- use App\Entity\Author;
- use Doctrine\Common\DataFixtures\DependentFixtureInterface;
- use Doctrine\Common\Persistence\ObjectManager;
- class NovelFixtures extends BaseFixture implements DependentFixtureInterface
- {
- public function loadData(ObjectManager $manager)
- {
- $this->createMany(Novel::class, 100, function(Novel $novel, $count) {
- $novel->setTitle($this->faker->sentence($nbWords = 4, $variableNbWords = true));
- $novel->setVisibility($this->faker->boolean($chanceOfGettingTrue = 85));
- $novel->setPublishedAt($this->faker->dateTime(null, $max = '-1 year'));
- $novel->setDescription($this->faker->paragraph($nbSentences = 3, $variableNbSentences = true));
- $novel->setCoverImage($this->faker->imageUrl($width = 175, $height = 225, null, false, $this->faker->word()));
- $novel->setAuthor($this->getRandomReference(Author::class));
- });
- $manager->flush();
- }
- public function getDependencies()
- {
- return [Author::class];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement