@php use App\Models\Commons\Menu; /** * 권한명을 파싱하여 메뉴 태그와 권한 타입을 시각적으로 표시 */ function formatPermissionName(string $permissionName): string { // menu:{menu_id}.{permission_type} 패턴 파싱 if (preg_match('/^menu:(\d+)\.(\w+)$/', $permissionName, $matches)) { $menuId = (int) $matches[1]; $permissionType = $matches[2]; // 메뉴 정보 조회 $menu = Menu::find($menuId); $menuName = $menu ? $menu->name : '알 수 없는 메뉴'; // 권한 타입별 설정 $permissionConfig = getPermissionConfig($permissionType); // HTML 생성 (Admin과 동일한 스타일) $html = '
'; // 메뉴 태그 (회색 배지) $html .= sprintf( '메뉴 #%d', $menuId ); // 메뉴명 $html .= sprintf( '%s', htmlspecialchars($menuName) ); // 권한 타입 배지 $html .= sprintf( '%s', $permissionConfig['style'], $permissionConfig['label'], $permissionConfig['badge'] ); $html .= '
'; return $html; } // 패턴이 일치하지 않으면 원본 반환 return '' . htmlspecialchars($permissionName) . ''; } /** * 권한 타입별 설정 반환 (Admin과 동일한 색상) */ function getPermissionConfig(string $type): array { $configs = [ 'view' => [ 'badge' => 'V', 'label' => '조회', 'style' => 'background-color: rgb(219 234 254); color: rgb(30 64 175);', ], 'create' => [ 'badge' => 'C', 'label' => '생성', 'style' => 'background-color: rgb(220 252 231); color: rgb(21 128 61);', ], 'update' => [ 'badge' => 'U', 'label' => '수정', 'style' => 'background-color: rgb(254 215 170); color: rgb(154 52 18);', ], 'delete' => [ 'badge' => 'D', 'label' => '삭제', 'style' => 'background-color: rgb(254 202 202); color: rgb(153 27 27);', ], 'approve' => [ 'badge' => 'A', 'label' => '승인', 'style' => 'background-color: rgb(233 213 255); color: rgb(107 33 168);', ], 'export' => [ 'badge' => 'E', 'label' => '내보내기', 'style' => 'background-color: rgb(207 250 254); color: rgb(14 116 144);', ], 'manage' => [ 'badge' => 'M', 'label' => '관리', 'style' => 'background-color: rgb(243 244 246); color: rgb(31 41 55);', ], ]; return $configs[$type] ?? [ 'badge' => strtoupper(substr($type, 0, 1)), 'label' => $type, 'style' => 'background-color: rgb(243 244 246); color: rgb(31 41 55);', ]; } @endphp
@forelse($permissions as $permission) @empty @endforelse
ID 권한명 테넌트 가드 할당된 역할 할당된 부서 생성일 수정일 액션
{{ $permission->id }} {!! formatPermissionName($permission->name) !!} @if($permission->tenant) {{ $permission->tenant->company_name }} @else 전역 @endif {{ $permission->guard_name }} @if($permission->roles->isNotEmpty())
@foreach($permission->roles as $role) {{ $role->name }} @endforeach
@else - @endif
@if($permission->departments->isNotEmpty())
@foreach($permission->departments as $department) {{ $department->name }} @endforeach
@else - @endif
{{ $permission->created_at?->format('Y-m-d H:i') ?? '-' }} {{ $permission->updated_at?->format('Y-m-d H:i') ?? '-' }} 수정
등록된 권한이 없습니다.
@include('partials.pagination', [ 'paginator' => $permissions, 'target' => '#permission-table', 'includeForm' => '#filterForm' ])