Files
sam-manage/app/Http/Controllers/HR/PayrollController.php

48 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\HR;
use App\Http\Controllers\Controller;
use App\Models\HR\Payroll;
use App\Services\HR\PayrollService;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class PayrollController extends Controller
{
private const ALLOWED_PAYROLL_USERS = ['이경호', '전진선', '김보곤'];
public function __construct(
private PayrollService $payrollService
) {}
/**
* 급여관리 페이지
*/
public function index(Request $request): View|Response
{
if ($request->header('HX-Request')) {
return response('', 200)->header('HX-Redirect', route('hr.payrolls.index'));
}
if (! in_array(auth()->user()->name, self::ALLOWED_PAYROLL_USERS)) {
return view('hr.payrolls.restricted');
}
$stats = $this->payrollService->getMonthlyStats();
$departments = $this->payrollService->getDepartments();
$employees = $this->payrollService->getActiveEmployees();
$settings = $this->payrollService->getSettings();
$statusMap = Payroll::STATUS_MAP;
return view('hr.payrolls.index', [
'stats' => $stats,
'departments' => $departments,
'employees' => $employees,
'settings' => $settings,
'statusMap' => $statusMap,
]);
}
}