*/ final class BlogPostFactory extends Factory { protected $model = BlogPost::class; public function definition(): array { $title = $this->faker->sentence(5); return [ 'slug' => Str::slug($title) . '-' . $this->faker->unique()->numberBetween(1, 99999), 'title' => $title, 'body' => '
' . implode('
', $this->faker->paragraphs(3)) . '
', 'excerpt' => $this->faker->sentence(15), 'author_id' => null, 'featured_image' => null, 'meta_title' => null, 'meta_description' => null, 'is_published' => true, 'published_at' => $this->faker->dateTimeBetween('-1 year', 'now'), ]; } public function draft(): static { return $this->state(['is_published' => false, 'published_at' => null]); } }