trypost/database/factories/PlanFactory.php
Paulo Castellano 2da15df96c feat: introduce Account entity as billing owner and refactor architecture
- Create Account model as Cashier Billable entity (stripe, plan, subscription)
- Account owns workspaces and has an owner_id (User)
- User belongs to one Account via account_id
- Workspace belongs to Account via account_id, no longer has billing fields
- Remove Brand model entirely (workspaces serve as grouping)
- Rename brand_limit to workspace_limit in plans
- Workspace roles simplified: admin/member/viewer (owner via Account)
- Invites now belong to Account with workspaces JSON array
- Pennant features scope changed from Workspace to Account
- EnsureSubscribed middleware checks Account subscription
- All controllers updated: BillingController, OnboardingController,
  WorkspaceInviteController, SocialController, StripeEventListener
- Frontend: extract GoogleAuthButton component, create WorkspaceRole
  enum for type-safe role checks, fix all views for new architecture
- All 1101 tests passing
2026-04-14 22:22:04 -03:00

47 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\Plan\Slug;
use App\Models\Plan;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Plan>
*/
class PlanFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'slug' => fake()->randomElement(Slug::cases()),
'name' => fake()->word(),
'stripe_monthly_price_id' => null,
'stripe_yearly_price_id' => null,
'monthly_price' => fake()->randomElement([900, 1900, 3900, 7900]),
'yearly_price' => fake()->randomElement([9000, 19000, 39000, 79000]),
'social_account_limit' => fake()->randomElement([3, 10, 25, 100]),
'member_limit' => fake()->randomElement([1, 3, 10, 50]),
'workspace_limit' => fake()->randomElement([1, 3, 10, 50]),
'ai_images_limit' => fake()->randomElement([10, 50, 200, 1000]),
'ai_videos_limit' => fake()->randomElement([5, 25, 100, 500]),
'data_retention_days' => fake()->randomElement([30, 90, 365, 730]),
'sort' => 0,
'is_archived' => false,
];
}
public function archived(): static
{
return $this->state(fn (array $attributes): array => [
'is_archived' => true,
]);
}
}