Gustavo Zanatta 2 долоо хоног өмнө
parent
commit
6aa2d37b32

+ 1 - 12
app/Services/DashboardService.php

@@ -110,11 +110,6 @@ class DashboardService
 
     $blockedProviderIds       = ScheduleBusinessRules::getBlockedProviderIdsForClient($cliente->id);
     $providersWithWorkingDays = ScheduleBusinessRules::getProviderIdsWithWorkingDays();
-    $clientAddress = Address::where('source', 'client')
-      ->where('source_id', $cliente->id)
-      ->orderBy('is_primary', 'desc')
-      ->first();
-
     $clientPrimaryAddress = Address::where('source', 'client')
       ->where('source_id', $cliente->id)
       ->where('is_primary', true)
@@ -127,16 +122,10 @@ class DashboardService
             *
           FROM addresses
           WHERE source = 'provider'
+          AND deleted_at IS NULL
           ORDER BY source_id, is_primary DESC
         ) as provider_address
       "), 'provider_address.source_id', '=', 'providers.id')
-      ->where('provider_address.city_id', '=', $clientAddress->city_id)
-      ->leftJoin('addresses as provider_address', function ($join) {
-        $join->on('provider_address.source_id', '=', 'providers.id')
-          ->where('provider_address.source', 'provider')
-          ->whereNull('provider_address.deleted_at')
-          ->orderBy('provider_address.is_primary', 'desc');
-      })
       ->whereNotNull('provider_address.id')
       ->where('provider_address.city_id', $clientPrimaryAddress?->city_id)
       ->whereNotIn('providers.id', $blockedProviderIds)