주요 변경사항: - Spatie Laravel Permission 패키지 설치 (v6.23.0) - admin 프로젝트에서 필수 Traits 및 Scopes 복사 - ModelTrait, BelongsToTenant, HasTenantFilter, UppercaseAttributes - TenantScope - Tenant 모델 관계 수정 (hasMany → belongsToMany via user_tenants) - Tenant 모델 null 처리 추가 (status_label, created_at) - Laravel 12 bootstrap/app.php에 API 라우트 등록 - API 라우트 미들웨어 수정 (auth:sanctum → web,auth) - HTMX 라이브러리 및 CSRF 토큰 헤더 추가 ViewServiceProvider 수정: - 전역 View Composer의 $tenants 변수를 $globalTenants로 변경 - 페이지별 페이지네이션된 $tenants 변수와의 충돌 방지 - tenant-selector.blade.php에서 $globalTenants 사용 버그 수정: - Collection::hasPages() 오류 해결 (ViewComposer 변수 덮어쓰기 문제) - 테넌트 목록 무한 로딩 스피너 해결 - 500 Internal Server Error 해결
148 lines
8.0 KiB
PHP
148 lines
8.0 KiB
PHP
<div class="overflow-x-auto">
|
|
<table class="min-w-full divide-y divide-gray-200">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">회사명</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">코드</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">상태</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">이메일</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">전화번호</th>
|
|
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">사용자</th>
|
|
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">부서</th>
|
|
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">메뉴</th>
|
|
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">역할</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">생성일</th>
|
|
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">액션</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white divide-y divide-gray-200">
|
|
@forelse($tenants as $tenant)
|
|
<tr class="{{ $tenant->deleted_at ? 'bg-gray-100' : '' }}">
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
|
{{ $tenant->id }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<div class="text-sm font-medium text-gray-900">{{ $tenant->company_name }}</div>
|
|
@if($tenant->ceo_name)
|
|
<div class="text-sm text-gray-500">대표: {{ $tenant->ceo_name }}</div>
|
|
@endif
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
|
{{ $tenant->code }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
|
|
{{ $tenant->status_badge_color === 'success' ? 'bg-green-100 text-green-800' : '' }}
|
|
{{ $tenant->status_badge_color === 'warning' ? 'bg-yellow-100 text-yellow-800' : '' }}
|
|
{{ $tenant->status_badge_color === 'error' ? 'bg-red-100 text-red-800' : '' }}">
|
|
{{ $tenant->status_label }}
|
|
</span>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
{{ $tenant->email ?? '-' }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
{{ $tenant->phone ?? '-' }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-900">
|
|
{{ $tenant->users_count ?? 0 }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-900">
|
|
{{ $tenant->departments_count ?? 0 }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-900">
|
|
{{ $tenant->menus_count ?? 0 }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-900">
|
|
{{ $tenant->roles_count ?? 0 }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
{{ $tenant->created_at?->format('Y-m-d') ?? '-' }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
|
@if($tenant->deleted_at)
|
|
<!-- 삭제된 항목 -->
|
|
<button onclick="confirmRestore({{ $tenant->id }}, '{{ $tenant->company_name }}')"
|
|
class="text-green-600 hover:text-green-900 mr-3">
|
|
복원
|
|
</button>
|
|
@if(auth()->user()?->is_super_admin)
|
|
<button onclick="confirmForceDelete({{ $tenant->id }}, '{{ $tenant->company_name }}')"
|
|
class="text-red-600 hover:text-red-900">
|
|
영구삭제
|
|
</button>
|
|
@endif
|
|
@else
|
|
<!-- 활성 항목 -->
|
|
<a href="{{ route('tenants.edit', $tenant->id) }}"
|
|
class="text-blue-600 hover:text-blue-900 mr-3">
|
|
수정
|
|
</a>
|
|
<button onclick="confirmDelete({{ $tenant->id }}, '{{ $tenant->company_name }}')"
|
|
class="text-red-600 hover:text-red-900">
|
|
삭제
|
|
</button>
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="12" class="px-6 py-12 text-center text-gray-500">
|
|
등록된 테넌트가 없습니다.
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- 페이지네이션 -->
|
|
@if($tenants->hasPages())
|
|
<div class="bg-white px-4 py-3 border-t border-gray-200 sm:px-6">
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex-1 flex justify-between sm:hidden">
|
|
@if($tenants->onFirstPage())
|
|
<span class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-400 bg-gray-100 cursor-not-allowed">
|
|
이전
|
|
</span>
|
|
@else
|
|
<button hx-get="{{ $tenants->previousPageUrl() }}"
|
|
hx-target="#tenant-table"
|
|
hx-include="#filterForm"
|
|
class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
|
|
이전
|
|
</button>
|
|
@endif
|
|
|
|
@if($tenants->hasMorePages())
|
|
<button hx-get="{{ $tenants->nextPageUrl() }}"
|
|
hx-target="#tenant-table"
|
|
hx-include="#filterForm"
|
|
class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
|
|
다음
|
|
</button>
|
|
@else
|
|
<span class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-400 bg-gray-100 cursor-not-allowed">
|
|
다음
|
|
</span>
|
|
@endif
|
|
</div>
|
|
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
|
|
<div>
|
|
<p class="text-sm text-gray-700">
|
|
전체 <span class="font-medium">{{ $tenants->total() }}</span>개 중
|
|
<span class="font-medium">{{ $tenants->firstItem() }}</span>
|
|
~
|
|
<span class="font-medium">{{ $tenants->lastItem() }}</span>
|
|
</p>
|
|
</div>
|
|
<div>
|
|
<nav class="relative z-0 inline-flex rounded-md shadow-sm -space-x-px" aria-label="Pagination">
|
|
{{ $tenants->links() }}
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif |