ldc-wenn-dann-mit-respekt/database/factories/HomeFactory.php
2023-05-09 15:21:00 +02:00

53 lines
1.4 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Home;
use App\Models\Product;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<\App\Models\Home>
*/
final class HomeFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Home::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
$part2_list = [];
for ($jj = 1; $jj <= 4; $jj++) {
array_push($part2_list, [
"value" => $this->faker->unique()->words(\rand(2, 8), true)
]);
}
return [
'seo_title' => fake()->word,
'seo_description' => fake()->text(160),
'part1_title' => fake()->word,
'part1_subtitle' => fake()->word,
'part1_text_1' => fake()->text,
'part1_text_2' => fake()->text,
'part1_text_3' => fake()->text,
'part2_title' => fake()->word,
'part2_subtitle' => fake()->word,
'part2_text' => fake()->text,
'part2_list' => $part2_list,
'part2_product1_id' => fake()->randomElement(Product::pluck('id')),
'part2_product2_id' => fake()->randomElement(Product::pluck('id')),
'part3_picture_alt' => fake()->word,
'part3_picture_title' => fake()->word,
];
}
}