84 lines
2.1 KiB
PHP
84 lines
2.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\HR;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
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,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 사원 상세 페이지
|
||
|
|
*/
|
||
|
|
public function show(int $id): View
|
||
|
|
{
|
||
|
|
$employee = $this->employeeService->getEmployeeById($id);
|
||
|
|
|
||
|
|
if (! $employee) {
|
||
|
|
abort(404, '사원 정보를 찾을 수 없습니다.');
|
||
|
|
}
|
||
|
|
|
||
|
|
return view('hr.employees.show', [
|
||
|
|
'employee' => $employee,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 사원 수정 폼
|
||
|
|
*/
|
||
|
|
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');
|
||
|
|
|
||
|
|
return view('hr.employees.edit', [
|
||
|
|
'employee' => $employee,
|
||
|
|
'departments' => $departments,
|
||
|
|
'ranks' => $ranks,
|
||
|
|
'titles' => $titles,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|