38 lines
967 B
PHP
38 lines
967 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Setting;
|
|
|
|
use App\Enums\Gender;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\Setting\UpdateProfileRequest;
|
|
use App\Services\Setting\ProfileService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class ProfileController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly ProfileService $profileService,
|
|
) {}
|
|
|
|
public function edit(): Response
|
|
{
|
|
$user = auth()->user()->load('profile');
|
|
|
|
return Inertia::render('admin/setting/Profile', [
|
|
'genders' => Gender::selectOptions(),
|
|
'user' => $user,
|
|
]);
|
|
}
|
|
|
|
public function update(UpdateProfileRequest $request): RedirectResponse
|
|
{
|
|
$this->profileService->update($request->validated());
|
|
|
|
Inertia::flash('success', 'Profil berhasil diperbarui.');
|
|
|
|
return redirect()->route('admin.setting.profile');
|
|
}
|
|
}
|