*/ class NotificationFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'user_id' => User::factory(), 'type' => fake()->randomElement(['consultation_approved', 'consultation_rejected', 'timeline_update', 'new_post']), 'data' => [ 'message' => fake()->sentence(), 'action_url' => fake()->url(), ], 'read_at' => null, 'sent_at' => fake()->optional()->dateTimeBetween('-7 days', 'now'), ]; } /** * Create a read notification. */ public function read(): static { return $this->state(fn (array $attributes) => [ 'read_at' => fake()->dateTimeBetween('-7 days', 'now'), ]); } /** * Create an unread notification. */ public function unread(): static { return $this->state(fn (array $attributes) => [ 'read_at' => null, ]); } /** * Create a sent notification. */ public function sent(): static { return $this->state(fn (array $attributes) => [ 'sent_at' => fake()->dateTimeBetween('-7 days', 'now'), ]); } }