*/ class WorkspaceInviteFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'workspace_id' => Workspace::factory(), 'invited_by' => User::factory(), 'email' => fake()->unique()->safeEmail(), 'token' => Str::random(64), 'role' => Role::Member, 'status' => InviteStatus::Pending, 'expires_at' => now()->addDays(7), ]; } public function expired(): static { return $this->state(fn (array $attributes) => [ 'expires_at' => now()->subDay(), 'status' => InviteStatus::Expired, ]); } public function accepted(): static { return $this->state(fn (array $attributes) => [ 'status' => InviteStatus::Accepted, 'accepted_at' => now(), ]); } public function cancelled(): static { return $this->state(fn (array $attributes) => [ 'status' => InviteStatus::Cancelled, ]); } }