dstpabuaran.com/app/Http/Controllers/Controller.php
Yoga Pangestu 6dbe9da581 feat: add payroll management features including payroll periods, adjustments, and payment processing
- 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.
2026-07-30 17:06:52 +07:00

26 lines
867 B
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Validation\ValidationException;
use Inertia\Inertia;
abstract class Controller
{
protected function handleAction(callable $action, string $successMessage, string $redirectRoute, array $parameters = []): RedirectResponse
{
try {
$action();
Inertia::flash('toast', ['type' => 'success', 'message' => $successMessage]);
} catch (ValidationException $e) {
$firstError = collect($e->errors())->flatten()->first();
Inertia::flash('toast', ['type' => 'error', 'message' => $firstError ?? 'Terjadi kesalahan.']);
} catch (\Exception $e) {
Inertia::flash('toast', ['type' => 'error', 'message' => $e->getMessage()]);
}
return to_route($redirectRoute, $parameters);
}
}