주요 변경사항: - 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 해결
60 lines
3.2 KiB
PHP
60 lines
3.2 KiB
PHP
<!-- Tenant Selector Card -->
|
|
<div class="bg-white rounded-lg shadow overflow-hidden">
|
|
<div class="p-6">
|
|
<div class="flex items-center justify-between">
|
|
<!-- 좌측: 테넌트 선택 -->
|
|
<div class="flex items-center gap-4">
|
|
<div class="flex items-center gap-2">
|
|
<svg class="w-5 h-5 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
|
|
</svg>
|
|
<label for="tenant-select" class="text-sm font-medium text-gray-700">테넌트 선택:</label>
|
|
</div>
|
|
|
|
<form action="{{ route('tenant.switch') }}" method="POST" id="tenant-switch-form">
|
|
@csrf
|
|
<select
|
|
name="tenant_id"
|
|
id="tenant-select"
|
|
onchange="document.getElementById('tenant-switch-form').submit()"
|
|
class="border-gray-300 rounded-lg text-sm focus:ring-primary focus:border-primary min-w-[200px]"
|
|
>
|
|
<option value="all" {{ session('selected_tenant_id') === null ? 'selected' : '' }}>
|
|
전체 보기
|
|
</option>
|
|
@if($globalTenants->isNotEmpty())
|
|
<option disabled>─────────</option>
|
|
@endif
|
|
@foreach($globalTenants as $tenant)
|
|
<option value="{{ $tenant->id }}" {{ session('selected_tenant_id') == $tenant->id ? 'selected' : '' }}>
|
|
{{ $tenant->company_name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- 우측: 현재 테넌트 정보 -->
|
|
<div class="flex items-center gap-2">
|
|
@if(session('selected_tenant_id'))
|
|
@php
|
|
$currentTenant = $globalTenants->firstWhere('id', session('selected_tenant_id'));
|
|
@endphp
|
|
@if($currentTenant)
|
|
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-primary/10 text-primary">
|
|
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
{{ $currentTenant->company_name }} 데이터만 표시 중
|
|
</span>
|
|
@endif
|
|
@else
|
|
<span class="text-xs text-gray-500">
|
|
전체 테넌트 데이터 표시 중
|
|
</span>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|