45 lines
1.3 KiB
PHP
45 lines
1.3 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\Services\Hr\EmployeeService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class ProfileController extends Controller
|
|
{
|
|
use FlashesEntityMessage;
|
|
|
|
public function __construct(
|
|
private readonly ProfileService $profileService,
|
|
private readonly EmployeeService $employeeService,
|
|
) {}
|
|
|
|
public function edit(Request $request): Response
|
|
{
|
|
$editData = $this->employeeService->findForEdit($request->user());
|
|
|
|
return Inertia::render('admin/account/Profile', [
|
|
'genders' => Gender::selectOptions(),
|
|
'user' => $editData['employee'],
|
|
'profilePhoto' => $editData['profilePhoto'],
|
|
]);
|
|
}
|
|
|
|
public function update(UpdateProfileRequest $request): RedirectResponse
|
|
{
|
|
$this->profileService->update($request->validated(), $request->user());
|
|
|
|
$this->flashUpdated('Profil');
|
|
|
|
return redirect()->route('admin.account.profile');
|
|
}
|
|
}
|