*/ class InvitationFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'code' => Invitation::generateCode(), 'email' => fake()->unique()->safeEmail(), 'invited_by' => User::factory(), 'expires_at' => now()->addDays(7), 'email_sent' => fake()->boolean(30), ]; } /** * Indicate that the invitation is expired. */ public function expired(): static { return $this->state(fn(array $attributes) => [ 'expires_at' => now()->subDay(), ]); } /** * Indicate that the invitation has been accepted. */ public function accepted(): static { return $this->state(fn(array $attributes) => [ 'accepted_at' => now(), 'user_id' => User::factory(), ]); } /** * Indicate that the email was sent. */ public function emailSent(): static { return $this->state(fn(array $attributes) => [ 'email_sent' => true, ]); } }