feat(profile): align settings with dashboard layout

This commit is contained in:
2026-07-31 03:41:51 +02:00
parent e47243f7dc
commit 73c601ddc2
18 changed files with 947 additions and 377 deletions

View File

@@ -2,26 +2,50 @@
namespace App\Http\Controllers;
use App\Http\Requests\Profile\UpdateProfileRequest;
use App\Models\User;
use App\Services\Auth\TwoFactorEnrollmentState;
use Illuminate\Http\Request;
use App\Services\Auth\SecurityEventRecorder;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;
class ProfileController extends Controller
{
/**
* Display the authenticated user's profile and security settings.
* Display the authenticated user's profile settings.
*/
public function __invoke(
Request $request,
TwoFactorEnrollmentState $enrollmentState
): Response {
public function show(): Response
{
return Inertia::render('Profile/Show');
}
/**
* Update the authenticated user's profile settings.
*/
public function update(
UpdateProfileRequest $request,
SecurityEventRecorder $securityEvents
): RedirectResponse {
/** @var User $user */
$user = $request->user();
$emailChanged = $user->email !== $request->validated('email');
return Inertia::render('Profile/Show', [
'twoFactor' => $enrollmentState->for($user),
$user->fill($request->validated());
if ($emailChanged) {
$user->email_verified_at = null;
}
$user->save();
$securityEvents->record('profile.updated', $user, $request, [
'email_changed' => $emailChanged,
]);
if ($emailChanged) {
$user->sendEmailVerificationNotification();
}
return redirect()->route('profile.show')
->with('success', 'Your profile has been updated.');
}
}