- Sidebar reorganized: Workspace group (connections, hashtags, labels, API keys, settings) and Account group (settings, usage, billing) - Account group only visible to owner and hidden in self-hosted mode - Onboarding simplified: role -> account (connect socials) -> completed -> redirect to /subscribe. Removed Subscription setup step. - Subscribe page redesigned with 4 plan cards, monthly/yearly toggle, trial info, and per-plan features list - Billing page redesigned following Sendkit layout (sections with sidebar labels) - Processing page uses usePoll with immediate watch for subscription activation - Cancel URL redirects directly to /subscribe - Account settings page with name and billing_email (syncs with Stripe) - Usage page with ring meters for all plan limits - Settings layout tabs only for user pages (profile, password, notifications). Workspace/API keys/billing are standalone pages. - GoogleAuthButton extracted as reusable component - WorkspaceRole TypeScript enum for type-safe role checks in frontend - Trial period changed to 7 days - Fixed onboarding loop when user confirms email - All 1101 tests passing
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\User;
|
|
|
|
use App\Enums\User\Setup;
|
|
use App\Enums\UserWorkspace\Role;
|
|
use App\Models\Account;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CreateUser
|
|
{
|
|
/**
|
|
* @param array{name: string, email: string, password?: string, timezone?: string, setup?: Setup, email_verified_at?: \DateTimeInterface|null} $data
|
|
*/
|
|
public static function execute(array $data): User
|
|
{
|
|
return DB::transaction(function () use ($data): User {
|
|
$isInviteRegistration = data_get($data, 'is_invite', false);
|
|
|
|
$account = Account::create([
|
|
'name' => data_get($data, 'name')."'s Account",
|
|
'billing_email' => data_get($data, 'email'),
|
|
]);
|
|
|
|
$user = User::create([
|
|
'name' => data_get($data, 'name'),
|
|
'email' => data_get($data, 'email'),
|
|
'password' => data_get($data, 'password'),
|
|
'setup' => data_get($data, 'setup', $isInviteRegistration ? Setup::Completed : Setup::Role),
|
|
'email_verified_at' => data_get($data, 'email_verified_at', $isInviteRegistration ? now() : null),
|
|
'account_id' => $account->id,
|
|
]);
|
|
|
|
$account->update(['owner_id' => $user->id]);
|
|
|
|
$workspace = Workspace::create([
|
|
'account_id' => $account->id,
|
|
'user_id' => $user->id,
|
|
'name' => $user->name."'s Workspace",
|
|
'timezone' => data_get($data, 'timezone', 'UTC'),
|
|
]);
|
|
|
|
$workspace->members()->attach($user->id, ['role' => Role::Member->value]);
|
|
|
|
$user->update(['current_workspace_id' => $workspace->id]);
|
|
|
|
return $user;
|
|
});
|
|
}
|
|
}
|