*/ class IssueManagementFactory extends Factory { protected $model = IssueManagement::class; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'location_id' => Location::factory(), 'sub_location_id' => SubLocation::factory(), 'classification_id' => Classification::factory(), 'sub_classification_id' => SubClassification::factory(), 'media_monitoring_id' => MediaMonitoring::factory(), 'issue' => $this->faker->randomElement(IssueSentiment::cases())->value, 'response' => $this->faker->randomElement(IssueSentiment::cases())->value, 'description' => $this->faker->paragraphs(2, true), ]; } /** * Indicate that the issue is positive. */ public function positive(): static { return $this->state(fn (array $attributes) => [ 'issue' => IssueSentiment::POSITIVE->value, 'response' => IssueSentiment::POSITIVE->value, ]); } /** * Indicate that the issue is negative. */ public function negative(): static { return $this->state(fn (array $attributes) => [ 'issue' => IssueSentiment::NEGATIVE->value, 'response' => $this->faker->randomElement([ IssueSentiment::POSITIVE->value, IssueSentiment::NEUTRAL->value, ]), ]); } /** * Indicate that the issue is neutral. */ public function neutral(): static { return $this->state(fn (array $attributes) => [ 'issue' => IssueSentiment::NEUTRAL->value, 'response' => IssueSentiment::NEUTRAL->value, ]); } /** * Indicate that the issue is crisis. */ public function crisis(): static { return $this->state(fn (array $attributes) => [ 'issue' => IssueSentiment::CRISIS->value, 'response' => $this->faker->randomElement([ IssueSentiment::POSITIVE->value, IssueSentiment::NEUTRAL->value, ]), ]); } /** * Indicate that the issue has no sub location. */ public function withoutSubLocation(): static { return $this->state(fn (array $attributes) => [ 'sub_location_id' => null, ]); } /** * Indicate that the issue has no sub classification. */ public function withoutSubClassification(): static { return $this->state(fn (array $attributes) => [ 'sub_classification_id' => null, ]); } }