diff --git a/app/Http/Controllers/Sales/SalesDashboardController.php b/app/Http/Controllers/Sales/SalesDashboardController.php index 289f15ed..a857427a 100644 --- a/app/Http/Controllers/Sales/SalesDashboardController.php +++ b/app/Http/Controllers/Sales/SalesDashboardController.php @@ -4,6 +4,7 @@ use App\Http\Controllers\Controller; use App\Models\Sales\SalesTenantManagement; +use App\Models\Sales\TenantProspect; use App\Models\Tenants\Tenant; use App\Models\User; use Illuminate\Http\JsonResponse; @@ -97,10 +98,15 @@ private function getDashboardData(Request $request): array 'confirmed_commission' => 0, // 확정 가입비 수당 ]; - // 테넌트 목록 (현재 로그인한 사용자가 속한 테넌트만, HQ 제외) - $currentUser = auth()->user(); - $tenants = $currentUser->tenants() - ->where('tenant_type', '!=', 'HQ') + // 테넌트 목록 (가망고객에서 전환된 테넌트만) + // 전환된 가망고객의 tenant_id 목록 조회 + $convertedTenantIds = TenantProspect::whereNotNull('tenant_id') + ->where('status', TenantProspect::STATUS_CONVERTED) + ->pluck('tenant_id') + ->toArray(); + + // 전환된 테넌트만 조회 + $tenants = Tenant::whereIn('id', $convertedTenantIds) ->orderBy('created_at', 'desc') ->get();