43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\AnnouncementCategory;
|
|
use App\Models\Announcement;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<Announcement>
|
|
*/
|
|
class AnnouncementFactory extends Factory
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$title = fake()->unique()->sentence(4);
|
|
|
|
return [
|
|
'slug' => Str::slug($title),
|
|
'title' => $title,
|
|
'category' => fake()->randomElement(AnnouncementCategory::cases()),
|
|
'excerpt' => fake()->paragraph(),
|
|
'content' => fake()->paragraphs(5, true),
|
|
'image' => null,
|
|
'is_featured' => fake()->boolean(20),
|
|
'meta_title' => fake()->sentence(4),
|
|
'meta_description' => fake()->sentence(10),
|
|
'published_at' => fake()->dateTimeBetween('-6 months', 'now'),
|
|
];
|
|
}
|
|
|
|
public function featured(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_featured' => true,
|
|
]);
|
|
}
|
|
}
|