|
@@ -200,7 +200,8 @@ class DashboardService
|
|
|
|
|
|
|
|
$clientPrimaryAddress = Address::where('source', 'client')
|
|
$clientPrimaryAddress = Address::where('source', 'client')
|
|
|
->where('source_id', $cliente->id)
|
|
->where('source_id', $cliente->id)
|
|
|
- ->where('is_primary', true)
|
|
|
|
|
|
|
+ ->orderByDesc('is_primary')
|
|
|
|
|
+ ->orderByDesc('id')
|
|
|
->first();
|
|
->first();
|
|
|
|
|
|
|
|
$clientDistanceAddress = $this->addressForDistance($cliente->id, $clientPrimaryAddress);
|
|
$clientDistanceAddress = $this->addressForDistance($cliente->id, $clientPrimaryAddress);
|
|
@@ -225,7 +226,11 @@ class DashboardService
|
|
|
FROM addresses
|
|
FROM addresses
|
|
|
WHERE source = 'provider'
|
|
WHERE source = 'provider'
|
|
|
AND deleted_at IS NULL
|
|
AND deleted_at IS NULL
|
|
|
- ORDER BY source_id, is_primary DESC
|
|
|
|
|
|
|
+ ORDER BY
|
|
|
|
|
+ source_id,
|
|
|
|
|
+ (latitude IS NOT NULL AND longitude IS NOT NULL) DESC,
|
|
|
|
|
+ is_primary DESC,
|
|
|
|
|
+ id DESC
|
|
|
) AS provider_address
|
|
) AS provider_address
|
|
|
"),
|
|
"),
|
|
|
'provider_address.source_id',
|
|
'provider_address.source_id',
|
|
@@ -239,7 +244,10 @@ class DashboardService
|
|
|
'providers.profile_media_id'
|
|
'providers.profile_media_id'
|
|
|
)
|
|
)
|
|
|
->whereNotNull('provider_address.id')
|
|
->whereNotNull('provider_address.id')
|
|
|
- ->where('provider_address.city_id', $clientPrimaryAddress?->city_id)
|
|
|
|
|
|
|
+ ->when(
|
|
|
|
|
+ $clientPrimaryAddress?->city_id,
|
|
|
|
|
+ fn ($query, int $cityId) => $query->where('provider_address.city_id', $cityId)
|
|
|
|
|
+ )
|
|
|
->whereNotIn('providers.id', $blockedProviderIds)
|
|
->whereNotIn('providers.id', $blockedProviderIds)
|
|
|
->whereIn('providers.id', $providersWithWorkingDays)
|
|
->whereIn('providers.id', $providersWithWorkingDays)
|
|
|
->whereNull('providers.deleted_at')
|
|
->whereNull('providers.deleted_at')
|
|
@@ -282,6 +290,11 @@ class DashboardService
|
|
|
|
|
|
|
|
unset($item->provider_photo_path);
|
|
unset($item->provider_photo_path);
|
|
|
|
|
|
|
|
|
|
+ $item->daily_price_8h_base = $item->daily_price_8h;
|
|
|
|
|
+ $item->daily_price_6h_base = $item->daily_price_6h;
|
|
|
|
|
+ $item->daily_price_4h_base = $item->daily_price_4h;
|
|
|
|
|
+ $item->daily_price_2h_base = $item->daily_price_2h;
|
|
|
|
|
+
|
|
|
$item->daily_price_8h = $this->applyCreditCardFee($item->daily_price_8h);
|
|
$item->daily_price_8h = $this->applyCreditCardFee($item->daily_price_8h);
|
|
|
$item->daily_price_6h = $this->applyCreditCardFee($item->daily_price_6h);
|
|
$item->daily_price_6h = $this->applyCreditCardFee($item->daily_price_6h);
|
|
|
$item->daily_price_4h = $this->applyCreditCardFee($item->daily_price_4h);
|
|
$item->daily_price_4h = $this->applyCreditCardFee($item->daily_price_4h);
|