ldc-legaulois/database/factories/BreedingPageFactory.php
2022-02-10 16:14:58 +01:00

71 lines
2.7 KiB
PHP

<?php
namespace Database\Factories;
use App\Enums\BreedingBlocType;
use App\Enums\InputType;
use App\Models\BreedingPage;
use Illuminate\Database\Eloquent\Factories\Factory;
class BreedingPageFactory extends Factory
{
protected static $i = 1;
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = BreedingPage::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$title = implode(' ', $this->faker->unique()->words(rand(6, 12)));
$front = (static::$i++ <= 3 ? true : false);
return [
'title' => $title,
'seo_title' => implode(' ', $this->faker->words(8)),
'seo_description' => implode(' ', $this->faker->words(25)),
'slug' => \Illuminate\Support\Str::slug($title),
'headerContent' => $this->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(' ', $this->faker->words(5)),
'subtitleContent' => $this->faker->text(300),
'content' => [
array_replace_recursive(
BreedingPage::getBlocks()[BreedingBlocType::bloc1()->value],
[
'type' => BreedingBlocType::bloc1(),
'content' => [
'dropdownArray' => [
'value' => (function () {
$out = [];
$max = rand(1, 3);
for ($i = 0; $i < $max; $i++) {
$out[] = [
'title' => $this->faker->sentence(8),
'html' =>
// phpcs:ignore Generic.Files.LineLength.TooLong
'<a href="#">En savoir + sur chenilles à pattes de poulets</a>&nbsp;'
. $this->faker->text(620)
];
}
return $out;
})()
]
]
]
),
],
'status' => $front ?: (bool)rand(0, 1)
];
}
}