ldc-legaulois/database/factories/BreedingPageFactory.php
Jérémy Munsch 90da93f5c5
- Fix miniAcf videoVimeo regex
LOT 3 de merde
2021-10-09 11:24:41 +02:00

65 lines
2.6 KiB
PHP

<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Enums\BreedingBlocType;
use App\Enums\InputType;
use App\Models\BreedingPage;
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$i = 1;
$factory->define(BreedingPage::class, function (Faker $faker) use (&$i) {
$title = implode(' ', $faker->unique()->words(rand(6, 12)));
$front = ($i++ <= 3 ? true : false);
return [
'title' => $title,
'seo_title' => implode(' ', $faker->words(8)),
'seo_description' => implode(' ', $faker->words(25)),
'slug' => \Illuminate\Support\Str::slug($title),
'headerContent' => $faker->text(300),
'media_type' => rand(0, 1) ? InputType::image() : InputType::videoVimeo(),
'picture' => '/assets/images/pages_elevages/breeding-page.jpg',
'picture_alt' => 'Image donnée par la créa pas au bonnes dimensions',
'video' => 'https://vimeo.com/537775766',
'subtitle' => implode(' ', $faker->words(5)),
'subtitleContent' => $faker->text(300),
'content' => [
array_replace_recursive(
BreedingPage::getBlocks()[BreedingBlocType::bloc1()->value],
[
'type' => BreedingBlocType::bloc1(),
'content' => [
'dropdownArray' => [
'value' => (function () use ($faker) {
$out = [];
$max = rand(1, 3);
for ($i = 0; $i < $max; $i++) {
$out[] = [
'title' => $faker->sentence(8),
'html' =>
// phpcs:ignore Generic.Files.LineLength.TooLong
'<a href="#">En savoir + sur chenilles à pattes de poulets</a>&nbsp;'
. $faker->text(620)
];
}
return $out;
})()
]
]
]
),
],
'status' => $front ?: (bool)rand(0, 1)
];
});