*/ class PlanFactory extends Factory { /** * Define the model's default state. * * A default plan is unlimited and not purchasable, matching the most * permissive tier so tests can opt into limits explicitly. * * @return array */ public function definition(): array { return [ 'key' => fake()->unique()->slug(2), 'name' => fake()->words(2, true), 'workspace_type' => WorkspaceType::Personal, 'stripe_price' => null, 'interval' => 'month', 'amount' => 0, 'seat_limit' => null, 'max_folders' => null, 'max_folder_depth' => null, 'max_notes_per_folder' => null, 'note_chars' => null, 'sort_order' => 0, 'is_active' => true, ]; } /** * Indicate that the plan is sold through Stripe at the given price. */ public function purchasable(?string $price = null): static { return $this->state(fn (array $attributes) => [ 'stripe_price' => $price ?? 'price_'.Str::random(12), ]); } /** * Indicate that the plan caps the given limits. */ public function limited(int $maxFolders, int $maxFolderDepth, int $maxNotesPerFolder, int $noteChars): static { return $this->state(fn (array $attributes) => [ 'max_folders' => $maxFolders, 'max_folder_depth' => $maxFolderDepth, 'max_notes_per_folder' => $maxNotesPerFolder, 'note_chars' => $noteChars, ]); } }