2026-03-29 22:24:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\App\Settings;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
refactor: organize middleware/requests into App/ subdirs, add Resources, fix auth routes
- Move middleware to App/ subdir (HandleInertiaRequests, HandleAppearance,
EnsureSubscribed, EnsureUserSetupIsComplete) matching Sendkit pattern
- Move all Form Requests into organized subdirs (App/Post, App/Workspace,
App/Media, App/Invite, App/Settings, App/Auth)
- Create AuthUserResource and AuthWorkspaceResource for HandleInertiaRequests
shared data (role inside currentWorkspace, matching Sendkit pattern)
- Split auth.php into 3 route groups (no middleware, guest, auth) matching
Sendkit pattern exactly
- Fix UserFactory to include all nullable attributes (current_workspace_id,
stripe_id, pm_type, pm_last_four, trial_ends_at)
- Fix SocialAccountResource (display_name not name)
- Update frontend for new auth prop structure
- 702 tests passing (2 pre-existing Mastodon failures)
2026-03-30 00:13:30 +00:00
|
|
|
use App\Http\Requests\App\Settings\ProfileDeleteRequest;
|
|
|
|
|
use App\Http\Requests\App\Settings\ProfileUpdateRequest;
|
2026-04-15 01:22:04 +00:00
|
|
|
use App\Models\Account;
|
2026-04-14 21:22:36 +00:00
|
|
|
use App\Models\Workspace;
|
2026-03-29 22:24:28 +00:00
|
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use Inertia\Inertia;
|
|
|
|
|
use Inertia\Response;
|
|
|
|
|
|
|
|
|
|
class ProfileController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function edit(Request $request): Response
|
|
|
|
|
{
|
|
|
|
|
return Inertia::render('settings/Profile', [
|
|
|
|
|
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
|
|
|
|
|
'status' => $request->session()->get('status'),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function update(ProfileUpdateRequest $request): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
$request->user()->fill($request->validated());
|
|
|
|
|
|
|
|
|
|
if ($request->user()->isDirty('email')) {
|
|
|
|
|
$request->user()->email_verified_at = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$request->user()->save();
|
|
|
|
|
|
|
|
|
|
session()->flash('flash.banner', __('settings.flash.profile_updated'));
|
|
|
|
|
session()->flash('flash.bannerStyle', 'success');
|
|
|
|
|
|
|
|
|
|
return to_route('app.profile.edit');
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 02:01:08 +00:00
|
|
|
public function uploadPhoto(Request $request): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
$request->validate([
|
|
|
|
|
'photo' => ['required', 'image', 'max:2048'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$user = $request->user();
|
|
|
|
|
$user->clearMediaCollection('avatar');
|
|
|
|
|
$user->addMedia($request->file('photo'), 'avatar');
|
|
|
|
|
$user->unsetRelation('media');
|
|
|
|
|
|
|
|
|
|
session()->flash('flash.banner', __('settings.flash.photo_updated'));
|
|
|
|
|
session()->flash('flash.bannerStyle', 'success');
|
|
|
|
|
|
|
|
|
|
return back();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function deletePhoto(Request $request): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
$user = $request->user();
|
|
|
|
|
$user->clearMediaCollection('avatar');
|
|
|
|
|
$user->unsetRelation('media');
|
|
|
|
|
|
|
|
|
|
session()->flash('flash.banner', __('settings.flash.photo_deleted'));
|
|
|
|
|
session()->flash('flash.bannerStyle', 'success');
|
|
|
|
|
|
|
|
|
|
return back();
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
public function updateLanguage(Request $request): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
$request->validate([
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
'locale' => ['required', 'string', 'in:'.implode(',', array_keys(config('languages.available')))],
|
2026-03-29 22:24:28 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
session()->flash('flash.banner', __('settings.flash.language_updated'));
|
|
|
|
|
session()->flash('flash.bannerStyle', 'success');
|
|
|
|
|
|
refactor: auth split layout, subscribe redesign, onboarding, i18n, cookie locale
Auth pages:
- Create AuthSplitLayout with animated feature slides (6 slides, 3 languages)
- All auth pages use split layout (form left, visual right)
- Add show/hide password toggle with tooltip on Register
- Legal footer only shown on Register via showLegal prop
Subscribe page:
- Redesign to match auth card pattern (centered, clean)
- Platform icons, feature checklist, dynamic trial days (trialDays - 1)
- Add "Switch workspace" link
- Full i18n (en, es, pt-BR)
Onboarding:
- Rename URLs: step1 -> role, step2 -> connect
- Add enforceStep() to prevent skipping/going back steps
- Redirect /onboarding to /onboarding/role
- Redesign Step2 with AuthSplitLayout and compact platform list
- 21 tests covering all step enforcement scenarios
Workspaces page:
- Redesign with AuthSplitLayout (list with avatars, current badge)
Language system:
- Move locale from DB to cookie (forever, unencrypted, session.domain)
- Create SetLocale middleware (sets cookie if missing, validates against config)
- Rename lang/pt-br to lang/pt-BR
- Add dayjs es locale
Other:
- Copy utils.ts from sendkit (formatNumber, formatMoney, copyToClipboard)
- ConfirmDeleteModal with text confirmation (sendkit pattern)
- i18n for ConfirmDeleteModal internal strings (common.php)
- EmptyState component for posts index
- Exact match for "All" posts in sidebar
- Posts breadcrumbs show current status filter
- DialogFooter buttons aligned left
- API Keys page redesign with Table, DropdownMenu, EmptyState
- Extract CreateApiKeyDialog and InviteMemberDialog to components
- Remove API Keys from sidebar
- DropdownMenuItem destructive variant for Remove action
2026-03-30 14:53:42 +00:00
|
|
|
return back()->withCookie(
|
|
|
|
|
cookie()->forever('locale', $request->locale, '/', config('session.domain'))
|
|
|
|
|
);
|
2026-03-29 22:24:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function destroy(ProfileDeleteRequest $request): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
$user = $request->user();
|
|
|
|
|
|
|
|
|
|
DB::transaction(function () use ($user) {
|
|
|
|
|
$user->update(['current_workspace_id' => null]);
|
|
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
$account = $user->account;
|
2026-03-29 22:24:28 +00:00
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
// Cancel account subscription if exists
|
|
|
|
|
if ($account && $account->subscribed(Account::SUBSCRIPTION_NAME)) {
|
|
|
|
|
$account->subscription(Account::SUBSCRIPTION_NAME)->cancelNow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($account) {
|
|
|
|
|
$account->subscriptions()->delete();
|
|
|
|
|
}
|
2026-04-14 21:22:36 +00:00
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
$ownedWorkspaces = Workspace::where('user_id', $user->id)->get();
|
|
|
|
|
|
|
|
|
|
foreach ($ownedWorkspaces as $workspace) {
|
2026-03-29 22:24:28 +00:00
|
|
|
foreach ($workspace->members as $member) {
|
|
|
|
|
if ($member->id !== $user->id && $member->current_workspace_id === $workspace->id) {
|
|
|
|
|
$otherWorkspace = $member->workspaces()
|
|
|
|
|
->where('workspaces.id', '!=', $workspace->id)
|
|
|
|
|
->first();
|
|
|
|
|
$member->update(['current_workspace_id' => $otherWorkspace?->id]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$workspace->posts()->delete();
|
|
|
|
|
$workspace->socialAccounts()->delete();
|
|
|
|
|
$workspace->hashtags()->delete();
|
|
|
|
|
$workspace->labels()->delete();
|
|
|
|
|
$workspace->members()->detach();
|
|
|
|
|
$workspace->delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user->workspaces()->detach();
|
2026-04-15 01:22:04 +00:00
|
|
|
|
|
|
|
|
if ($account) {
|
|
|
|
|
$account->delete();
|
|
|
|
|
}
|
2026-03-29 22:24:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Auth::logout();
|
|
|
|
|
$user->delete();
|
|
|
|
|
$request->session()->invalidate();
|
|
|
|
|
$request->session()->regenerateToken();
|
|
|
|
|
|
|
|
|
|
return redirect('/');
|
|
|
|
|
}
|
|
|
|
|
}
|