*/ class MediaMonitoringFactory extends Factory { protected $model = MediaMonitoring::class; /** * Define the model's default state. * * @return array */ public function definition(): array { $mediaNames = [ 'Kompas.com', 'Detik.com', 'Tribun News', 'Liputan6', 'CNN Indonesia', 'ANTARA News', 'Tempo.co', 'Okezone', 'Suara.com', 'Bisnis.com', ]; $channels = [ 'Website', 'Facebook', 'Instagram', 'Twitter', 'YouTube', 'TikTok', 'WhatsApp', 'Telegram', 'LinkedIn', ]; return [ 'code' => $this->faker->unique()->regexify('[A-Z]{2}[0-9]{8}'), 'media_name' => $this->faker->randomElement($mediaNames), 'title' => $this->faker->sentence(6), 'channel' => $this->faker->randomElement($channels), 'writter' => $this->faker->name(), 'link' => $this->faker->optional(0.8)->url(), 'news_page' => $this->faker->optional(0.3)->numberBetween(1, 20), 'quote' => $this->faker->optional(0.4)->paragraph(), 'content' => $this->faker->paragraphs(3, true), 'influencer' => $this->faker->optional(0.2)->name(), 'keyword' => implode(', ', $this->faker->words(3)), 'release_date' => $this->faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d'), ]; } /** * Indicate that the media monitoring is for online media. */ public function online(): static { return $this->state(fn (array $attributes) => [ 'channel' => $this->faker->randomElement(['Website', 'Facebook', 'Instagram', 'Twitter']), 'link' => $this->faker->url(), 'news_page' => null, ]); } /** * Indicate that the media monitoring is for print media. */ public function print(): static { return $this->state(fn (array $attributes) => [ 'channel' => 'Print', 'link' => null, 'news_page' => $this->faker->numberBetween(1, 20), ]); } /** * Indicate that the media monitoring has influencer mention. */ public function withInfluencer(): static { return $this->state(fn (array $attributes) => [ 'influencer' => $this->faker->name(), ]); } /** * Indicate that the media monitoring has quote. */ public function withQuote(): static { return $this->state(fn (array $attributes) => [ 'quote' => $this->faker->paragraph(), ]); } }