45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Account;
|
|
|
|
use App\Enums\Gender;
|
|
use App\Http\Controllers\Concerns\FlashesEntityMessage;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\Account\UpdateProfileRequest;
|
|
use App\Services\Account\ProfileService;
|
|
use App\Support\Media\MediaPresenter;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class ProfileController extends Controller
|
|
{
|
|
use FlashesEntityMessage;
|
|
|
|
public function __construct(
|
|
private readonly ProfileService $profileService,
|
|
) {}
|
|
|
|
public function edit(): Response
|
|
{
|
|
$user = auth()->user()->load('profile');
|
|
|
|
return Inertia::render('admin/account/Profile', [
|
|
'genders' => Gender::selectOptions(),
|
|
'user' => $user,
|
|
'profilePhoto' => $user->profile
|
|
? MediaPresenter::first($user->profile, 'profile_photo')
|
|
: null,
|
|
]);
|
|
}
|
|
|
|
public function update(UpdateProfileRequest $request): RedirectResponse
|
|
{
|
|
$this->profileService->update($request->validated(), $request->user());
|
|
|
|
$this->flashUpdated('Profil');
|
|
|
|
return redirect()->route('admin.account.profile');
|
|
}
|
|
}
|