|
|
@@ -11,12 +11,10 @@ use App\Models\ClientFavoriteProvider;
|
|
|
use App\Models\ClientPaymentMethod;
|
|
|
use App\Models\Notification;
|
|
|
use App\Models\Provider;
|
|
|
-use App\Models\ProviderSpeciality;
|
|
|
use App\Models\Review;
|
|
|
use App\Models\Schedule;
|
|
|
use App\Models\ScheduleProposal;
|
|
|
use App\Models\ServicePackage;
|
|
|
-use App\Models\Speciality;
|
|
|
use App\Rules\ScheduleBusinessRules;
|
|
|
use Illuminate\Auth\Access\AuthorizationException;
|
|
|
use Illuminate\Support\Collection;
|
|
|
@@ -671,6 +669,7 @@ class DashboardService
|
|
|
|
|
|
$solicitations = Schedule::with([
|
|
|
'address:district,source_id,source,id,zip_code,latitude,longitude',
|
|
|
+ 'customSchedule.specialities',
|
|
|
])
|
|
|
->where('schedules.provider_id', $provider->id)
|
|
|
->where('schedules.status', 'pending')
|
|
|
@@ -728,9 +727,11 @@ class DashboardService
|
|
|
LIMIT 1
|
|
|
) AS service_package_id
|
|
|
"),
|
|
|
- )
|
|
|
- ->orderBy('schedules.date', 'asc')
|
|
|
- ->get();
|
|
|
+ )
|
|
|
+ ->orderBy('schedules.date', 'asc')
|
|
|
+ ->get()
|
|
|
+ ->append('specialities')
|
|
|
+ ->makeHidden('customSchedule');
|
|
|
|
|
|
$solicitations->each(function ($solicitation) use ($address) {
|
|
|
$solicitation->distance_km = $this->zipCodeCoordinatesService->calculateDistance(
|
|
|
@@ -895,13 +896,16 @@ class DashboardService
|
|
|
|
|
|
$cliente = Client::where('user_id', $user->id)->firstOrFail();
|
|
|
|
|
|
- $schedule = Schedule::where('schedules.id', $scheduleId)
|
|
|
+ $schedule = Schedule::with('customSchedule.specialities')
|
|
|
+ ->where('schedules.id', $scheduleId)
|
|
|
->where('schedules.client_id', $cliente->id)
|
|
|
->leftJoin('providers', 'providers.id', '=', 'schedules.provider_id')
|
|
|
->leftJoin('users as provider_user', 'provider_user.id', '=', 'providers.user_id')
|
|
|
->leftJoin('custom_schedules', 'custom_schedules.schedule_id', '=', 'schedules.id')
|
|
|
->select(
|
|
|
+ 'schedules.id',
|
|
|
'schedules.provider_id',
|
|
|
+ 'schedules.schedule_type',
|
|
|
'provider_user.name as provider_name',
|
|
|
'providers.birth_date as provider_birth_date',
|
|
|
'providers.gender',
|
|
|
@@ -912,28 +916,14 @@ class DashboardService
|
|
|
$providerPhoto = $this->providerPhotoUrls([$schedule->provider_id])
|
|
|
->get($schedule->provider_id);
|
|
|
|
|
|
- $allSpecialities = Speciality::where('active', true)
|
|
|
- ->select('id', 'description')
|
|
|
- ->orderBy('description')
|
|
|
- ->get();
|
|
|
-
|
|
|
- $providerSpecialityIds = ProviderSpeciality::where('provider_id', $schedule->provider_id)
|
|
|
- ->pluck('speciality_id')
|
|
|
- ->all();
|
|
|
-
|
|
|
- $specialities = $allSpecialities->map(fn($sp) => [
|
|
|
- 'id' => $sp->id,
|
|
|
- 'description' => $sp->description,
|
|
|
- 'has_speciality' => in_array($sp->id, $providerSpecialityIds),
|
|
|
- ])->values();
|
|
|
-
|
|
|
return [
|
|
|
+ 'schedule_type' => $schedule->schedule_type,
|
|
|
'provider_name' => $schedule->provider_name,
|
|
|
'provider_birth_date' => $schedule->provider_birth_date,
|
|
|
'gender' => $schedule->gender,
|
|
|
'gender_label' => GenderEnum::labelFor($schedule->gender),
|
|
|
'offers_meal' => $schedule->offers_meal,
|
|
|
- 'specialities' => $specialities,
|
|
|
+ 'specialities' => $schedule->specialities,
|
|
|
|
|
|
'provider_photo' => $providerPhoto,
|
|
|
];
|