- Implemented routes for managing payroll periods, including current, close, and reopen functionalities. - Added payroll payment and cancellation routes. - Introduced payroll adjustments with store and delete functionalities. - Created comprehensive feature tests for payroll management, covering authentication, CRUD operations, and business logic. - Ensured proper handling of payroll adjustments and their impact on payroll totals. - Developed tests for generating payrolls and managing payroll periods, ensuring accurate status transitions and data integrity.
61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Settings;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Settings\ProfileUpdateRequest;
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class ProfileController extends Controller
|
|
{
|
|
/**
|
|
* Show the user's profile settings page.
|
|
*/
|
|
public function edit(Request $request): Response
|
|
{
|
|
$user = $request->user();
|
|
$user->load('userProfile');
|
|
|
|
return Inertia::render('settings/profile', [
|
|
'mustVerifyEmail' => $user instanceof MustVerifyEmail,
|
|
'status' => $request->session()->get('status'),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Update the user's profile information.
|
|
*/
|
|
public function update(ProfileUpdateRequest $request): RedirectResponse
|
|
{
|
|
$validated = $request->validated();
|
|
$user = $request->user();
|
|
|
|
$user->fill(['email' => $validated['email']]);
|
|
|
|
if ($user->isDirty('email')) {
|
|
$user->email_verified_at = null;
|
|
}
|
|
|
|
$user->save();
|
|
|
|
$user->userProfile()->updateOrCreate(
|
|
[],
|
|
[
|
|
'full_name' => $validated['name'],
|
|
'phone_number' => $validated['phone_number'] ?? null,
|
|
'gender' => $validated['gender'] ?? null,
|
|
'birth_date' => $validated['birth_date'] ?? null,
|
|
'address' => $validated['address'] ?? null,
|
|
],
|
|
);
|
|
|
|
Inertia::flash('toast', ['type' => 'success', 'message' => __('Profile updated.')]);
|
|
|
|
return to_route('profile.edit');
|
|
}
|
|
}
|