faker->sentence(6); $status = $this->faker->randomElement(ArticleStatus::cases()); return [ 'author_id' => User::factory(), 'title' => $title, 'slug' => Str::slug($title.'-'.$this->faker->unique()->randomNumber()), 'excerpt' => $this->faker->paragraph(), 'content' => $this->faker->paragraphs(3, true), 'status' => $status, 'published_at' => $status === ArticleStatus::PUBLISHED ? $this->faker->dateTimeBetween('-10 days', 'now') : null, 'views' => $this->faker->numberBetween(0, 1000), ]; } public function draft(): Factory { return $this->state(fn () => [ 'status' => ArticleStatus::DRAFT, 'published_at' => null, ]); } public function published(): Factory { return $this->state(fn () => [ 'status' => ArticleStatus::PUBLISHED, 'published_at' => now(), ]); } }