first commit

This commit is contained in:
2026-10-09 08:21:06 +02:00
parent db7456df87
commit d259c62304
3761 changed files with 896046 additions and 0 deletions
@@ -0,0 +1,52 @@
<?php
namespace App\Http\Controllers\Web\Profile;
use App\Http\Controllers\Controller;
use App\Repositories\Country\CountryRepository;
use App\Repositories\Role\RoleRepository;
use App\Repositories\User\UserRepository;
use App\Support\Authorization\PasswordChangeManager;
use App\Support\Enum\UserStatus;
use App\Support\Options;
use App\Support\UserPayload;
use Inertia\Inertia;
use Inertia\Response as InertiaResponse;
class ProfileController extends Controller
{
public function __construct(
private readonly UserRepository $users,
private readonly RoleRepository $roles,
private readonly CountryRepository $countries
) {}
public function show(PasswordChangeManager $passwordChangeManager): InertiaResponse
{
$user = auth()->user();
// The role and status selects are disabled on the profile, so only the
// user's own role is offered rather than the full list.
$roles = $this->roles->all()
->filter(fn ($role) => $role->id == $user->role_id)
->pluck('display_name', 'id');
$forcePasswordChange = $passwordChangeManager->isPasswordChangeForcedForUser($user);
return Inertia::render('Profile', [
'user' => UserPayload::form($user),
'roles' => Options::fromList($roles),
'countries' => Options::fromList(
[0 => __('Select a Country')] + $this->countries->lists()->toArray()
),
'statuses' => Options::fromList(UserStatus::lists()),
'avatarSources' => UserPayload::avatarSources(
$user,
$this->users->getUserSocialLogins($user->id)
),
'twoFactor' => UserPayload::twoFactor($user),
'forcePasswordChange' => $forcePasswordChange,
'activeTab' => $forcePasswordChange ? 'login' : (session('tab') ?? 'details'),
]);
}
}