25 lines
582 B
PHP
25 lines
582 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Content;
|
|
use App\Models\Page;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class ContentFactory extends Factory
|
|
{
|
|
protected $model = Content::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$type = fake()->randomElement(['text', 'image', 'video']);
|
|
|
|
return [
|
|
'page_id' => Page::factory(),
|
|
'type' => $type,
|
|
'body' => $type === 'text' ? fake()->paragraph() : fake()->imageUrl(),
|
|
'title' => fake()->optional()->sentence(),
|
|
];
|
|
}
|
|
}
|