*/ class BeritaFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { $kategoris = ['Akademik', 'Non-Akademik', 'Kegiatan Sekolah', 'Pengumuman', 'Prestasi']; $statuses = ['draft', 'published']; return [ 'judul' => fake()->sentence(6), 'kategori' => fake()->randomElement($kategoris), 'ringkasan' => fake()->paragraph(2), 'isi' => fake()->paragraphs(5, true), 'gambar' => null, // Set to null for now, can be updated later 'penulis' => fake()->name(), 'status' => fake()->randomElement($statuses), ]; } /** * Indicate that the berita is published. */ public function published(): static { return $this->state(fn (array $attributes) => [ 'status' => 'published', ]); } /** * Indicate that the berita is draft. */ public function draft(): static { return $this->state(fn (array $attributes) => [ 'status' => 'draft', ]); } }