Pricing - Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the workspace count and syncs on workspace create/delete. - 2,500 AI credits per workspace, pooled at the account level; monthly reset on the billing anniversary, annual granted upfront (no rollover). - One social account per network per workspace; remove all count-based limits (workspace/social/member) and the legacy plan tiers (single Workspace plan). Onboarding (cloud only: SELF_HOSTED=false + PostHog) - Replace the /subscribe plan picker with /onboarding persona selection (Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user (users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly price. 8-day trial so Stripe displays 7. Billing screen - Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade banner for monthly subscribers (swapToYearly). - Current-plan card shows the workspace count instead of the plan name. System AI - Brand analyzer / workspace autofill is always allowed and never debits credits (system feature, not the user's usage). Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network, and onboarding logic.
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Workspace;
|
|
|
|
use App\Enums\UserWorkspace\Role;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
|
|
class CreateWorkspace
|
|
{
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
*/
|
|
public static function execute(User $user, array $data): Workspace
|
|
{
|
|
$attributes = array_filter([
|
|
'name' => data_get($data, 'name'),
|
|
'brand_website' => data_get($data, 'brand_website'),
|
|
'brand_description' => data_get($data, 'brand_description'),
|
|
'brand_voice_traits' => data_get($data, 'brand_voice_traits'),
|
|
'brand_color' => data_get($data, 'brand_color'),
|
|
'background_color' => data_get($data, 'background_color'),
|
|
'text_color' => data_get($data, 'text_color'),
|
|
'content_language' => data_get($data, 'content_language'),
|
|
], static fn ($value): bool => $value !== null);
|
|
|
|
$workspace = Workspace::create([
|
|
...$attributes,
|
|
'account_id' => $user->account_id,
|
|
'user_id' => $user->id,
|
|
]);
|
|
|
|
// Creator becomes Admin of the workspace they made. The Account Owner
|
|
// is resolved separately (via account.owner_id) and outranks this role.
|
|
$workspace->members()->attach($user->id, ['role' => Role::Admin->value]);
|
|
$user->switchWorkspace($workspace);
|
|
|
|
$user->account?->forgetPlanFeatureCache();
|
|
$user->account?->syncWorkspaceQuantity();
|
|
|
|
return $workspace;
|
|
}
|
|
}
|