*/ class CommentFactory extends Factory { /** * @return array */ public function definition(): array { return [ 'commentable_id' => Course::factory(), 'commentable_type' => Course::class, 'name_surname' => fake()->name(), 'phone' => fake()->phoneNumber(), 'body' => fake()->paragraph(), 'admin_reply' => null, 'is_approved' => false, ]; } public function approved(): static { return $this->state(fn (array $attributes) => [ 'is_approved' => true, ]); } public function withReply(): static { return $this->state(fn (array $attributes) => [ 'admin_reply' => fake()->paragraph(), 'is_approved' => true, ]); } }