trypost/app/Http/Controllers/App/Settings/AccountController.php
Paulo Castellano ded1c998ec feat: redesign billing, onboarding, sidebar, and settings architecture
- 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
2026-04-15 00:33:38 -03:00

59 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers\App\Settings;
use App\Http\Controllers\App\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class AccountController extends Controller
{
public function edit(Request $request): Response
{
abort_unless($request->user()->isAccountOwner(), SymfonyResponse::HTTP_FORBIDDEN);
$account = $request->user()->account;
return Inertia::render('settings/Account', [
'account' => [
'id' => $account->id,
'name' => $account->name,
'billing_email' => $account->billing_email,
],
]);
}
public function update(Request $request): RedirectResponse
{
abort_unless($request->user()->isAccountOwner(), SymfonyResponse::HTTP_FORBIDDEN);
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
'billing_email' => ['required', 'email', 'max:255'],
]);
$account = $request->user()->account;
$account->update([
'name' => data_get($validated, 'name'),
'billing_email' => data_get($validated, 'billing_email'),
]);
if ($account->hasStripeId()) {
$account->updateStripeCustomer([
'name' => data_get($validated, 'name'),
'email' => data_get($validated, 'billing_email'),
]);
}
session()->flash('flash.banner', __('settings.flash.account_updated'));
session()->flash('flash.bannerStyle', 'success');
return back();
}
}