- Employee, Position 모델 생성 (tenant_user_profiles, positions 테이블) - EmployeeService 생성 (CRUD, 통계, 필터/검색/페이지네이션) - 뷰 컨트롤러(HR/EmployeeController) + API 컨트롤러 생성 - Blade 뷰: index(통계카드+HTMX테이블), create, edit, show, partials/table - 라우트: web.php(/hr/employees/*), api.php(/admin/hr/employees/*)
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,
|
|
]);
|
|
}
|
|
}
|