*/ class ArticleFactory extends Factory { protected $model = Article::class; public function definition(): array { $title = $this->faker->sentence(6); $slug = Str::slug($title) ?: 'article-'.Str::random(10); return [ 'title' => $title, 'slug' => $slug, 'summary' => $this->faker->optional()->paragraph(), 'content' => $this->faker->paragraphs(5, true), 'content_type' => Article::CONTENT_TYPE_BLOG, 'status' => Article::STATUS_PUBLISHED, 'access_level' => Article::ACCESS_LEVEL_PUBLIC, 'featured_image_path' => null, 'featured_image_alt' => null, 'author_name' => $this->faker->optional()->name(), 'author_user_id' => null, 'meta_description' => $this->faker->optional()->sentence(), 'meta_keywords' => null, 'is_pinned' => false, 'display_order' => 0, 'published_at' => now()->subDay(), 'expires_at' => null, 'archived_at' => null, 'view_count' => 0, 'created_by_user_id' => User::factory(), 'last_updated_by_user_id' => User::factory(), ]; } public function draft(): static { return $this->state(fn () => [ 'status' => Article::STATUS_DRAFT, 'published_at' => null, ]); } public function pinned(int $order = 0): static { return $this->state(fn () => [ 'is_pinned' => true, 'display_order' => $order, ]); } public function expired(): static { return $this->state(fn () => [ 'status' => Article::STATUS_PUBLISHED, 'expires_at' => now()->subDay(), ]); } public function scheduled(): static { return $this->state(fn () => [ 'status' => Article::STATUS_PUBLISHED, 'published_at' => now()->addDay(), ]); } }