fix: [rd] 조직도 Blade 템플릿 ParseError 수정

- @json 내 화살표 함수를 컨트롤러로 이동
- Blade 컴파일러와 배열 구문 충돌 해결
This commit is contained in:
김보곤
2026-03-06 19:37:06 +09:00
parent 774a35e097
commit 399813a16f
2 changed files with 13 additions and 13 deletions

View File

@@ -50,19 +50,25 @@ public function orgChart(Request $request): View|\Illuminate\Http\Response
->get();
// 전체 직원 (활성 상태)
$employees = Employee::withoutGlobalScopes()
$rawEmployees = Employee::withoutGlobalScopes()
->where('tenant_id', $tenantId)
->where('employee_status', 'active')
->with(['user', 'department'])
->orderBy('display_name')
->get();
// 미배치 직원 (department_id가 null)
$unassigned = $employees->whereNull('department_id');
// 배치된 직원을 부서별로 그룹핑
$assignedByDept = $employees->whereNotNull('department_id')->groupBy('department_id');
// Blade @json 호환을 위해 미리 배열로 변환
$employees = $rawEmployees->map(function ($e) {
return [
'id' => $e->id,
'user_id' => $e->user_id,
'department_id' => $e->department_id,
'display_name' => $e->display_name ?? $e->user?->name ?? '(이름없음)',
'position_label' => $e->position_label,
];
})->values();
return view('rd.org-chart', compact('departments', 'employees', 'unassigned', 'assignedByDept'));
return view('rd.org-chart', compact('departments', 'employees'));
}
/**

View File

@@ -201,13 +201,7 @@ class="fixed bottom-6 right-6 bg-gray-800 text-white px-4 py-2 rounded-lg shadow
function orgChart() {
return {
departments: @json($departments),
employees: @json($employees->map(fn($e) => [
'id' => $e->id,
'user_id' => $e->user_id,
'department_id' => $e->department_id,
'display_name' => $e->display_name ?? $e->user?->name ?? '(이름없음)',
'position_label' => $e->position_label,
])),
employees: @json($employees),
searchUnassigned: '',
saving: false,
sortables: [],