2026-02-26 16:43:52 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\HR;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2026-02-26 19:59:15 +09:00
|
|
|
use App\Models\Boards\File;
|
2026-02-26 16:43:52 +09:00
|
|
|
use App\Services\HR\EmployeeService;
|
|
|
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
|
|
|
|
|
|
class EmployeeController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private EmployeeService $employeeService
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 사원 목록 페이지
|
|
|
|
|
*/
|
|
|
|
|
public function index(): View
|
|
|
|
|
{
|
|
|
|
|
$stats = $this->employeeService->getStats();
|
|
|
|
|
$departments = $this->employeeService->getDepartments();
|
|
|
|
|
|
|
|
|
|
return view('hr.employees.index', [
|
|
|
|
|
'stats' => $stats,
|
|
|
|
|
'departments' => $departments,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 사원 등록 폼
|
|
|
|
|
*/
|
|
|
|
|
public function create(): View
|
|
|
|
|
{
|
|
|
|
|
$departments = $this->employeeService->getDepartments();
|
|
|
|
|
$ranks = $this->employeeService->getPositions('rank');
|
|
|
|
|
$titles = $this->employeeService->getPositions('title');
|
|
|
|
|
|
|
|
|
|
return view('hr.employees.create', [
|
|
|
|
|
'departments' => $departments,
|
|
|
|
|
'ranks' => $ranks,
|
|
|
|
|
'titles' => $titles,
|
2026-02-26 19:59:15 +09:00
|
|
|
'banks' => config('banks', []),
|
2026-02-26 16:43:52 +09:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 사원 상세 페이지
|
|
|
|
|
*/
|
|
|
|
|
public function show(int $id): View
|
|
|
|
|
{
|
|
|
|
|
$employee = $this->employeeService->getEmployeeById($id);
|
|
|
|
|
|
|
|
|
|
if (! $employee) {
|
|
|
|
|
abort(404, '사원 정보를 찾을 수 없습니다.');
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-26 19:59:15 +09:00
|
|
|
$files = File::where('document_type', 'employee_profile')
|
|
|
|
|
->where('document_id', $employee->id)
|
|
|
|
|
->where('tenant_id', session('selected_tenant_id'))
|
|
|
|
|
->orderBy('created_at', 'desc')
|
|
|
|
|
->get();
|
|
|
|
|
|
2026-02-26 16:43:52 +09:00
|
|
|
return view('hr.employees.show', [
|
|
|
|
|
'employee' => $employee,
|
2026-02-26 19:59:15 +09:00
|
|
|
'files' => $files,
|
2026-02-26 16:43:52 +09:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 사원 수정 폼
|
|
|
|
|
*/
|
|
|
|
|
public function edit(int $id): View
|
|
|
|
|
{
|
|
|
|
|
$employee = $this->employeeService->getEmployeeById($id);
|
|
|
|
|
|
|
|
|
|
if (! $employee) {
|
|
|
|
|
abort(404, '사원 정보를 찾을 수 없습니다.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$departments = $this->employeeService->getDepartments();
|
|
|
|
|
$ranks = $this->employeeService->getPositions('rank');
|
|
|
|
|
$titles = $this->employeeService->getPositions('title');
|
|
|
|
|
|
2026-02-26 19:59:15 +09:00
|
|
|
$files = File::where('document_type', 'employee_profile')
|
|
|
|
|
->where('document_id', $employee->id)
|
|
|
|
|
->where('tenant_id', session('selected_tenant_id'))
|
|
|
|
|
->orderBy('created_at', 'desc')
|
|
|
|
|
->get();
|
|
|
|
|
|
2026-02-26 16:43:52 +09:00
|
|
|
return view('hr.employees.edit', [
|
|
|
|
|
'employee' => $employee,
|
|
|
|
|
'departments' => $departments,
|
|
|
|
|
'ranks' => $ranks,
|
|
|
|
|
'titles' => $titles,
|
2026-02-26 19:59:15 +09:00
|
|
|
'banks' => config('banks', []),
|
|
|
|
|
'files' => $files,
|
2026-02-26 16:43:52 +09:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|