5 Commits 894cc7376a ... 06b0382ecd

Author SHA1 Message Date
  Gustavo Zanatta 06b0382ecd merge 1 day ago
  Gustavo Zanatta ab06cc17d8 Merge branch 'development' into feature/diariaapp-kay-agendamentos-sob-medida-apps 1 day ago
  Gustavo Zanatta b479ee2e01 Merge branch 'feature/diariaapp-kay-agendamentos-sob-medida-apps' of gogs.softpar.inf.br:Softpar/sfp_api_laravel_diarista into feature/diariaapp-kay-agendamentos-sob-medida-apps 1 day ago
  kayo henrique 57f405bd48 feat: :sparkles: feat(agendamento-sob-medida) Foi ajutsado o retorno das schedules proposals 1 day ago
  kayo henrique db3cc52a55 feat: :sparkles: feat(agendamento-sob-medida) foi realizado o ajuste para garantir o carregamento correto das propostas dos clientes 3 days ago
2 changed files with 35 additions and 0 deletions
  1. 1 0
      app/Http/Resources/DashboardClienteResource.php
  2. 34 0
      app/Services/DashboardService.php

+ 1 - 0
app/Http/Resources/DashboardClienteResource.php

@@ -22,6 +22,7 @@ class DashboardClienteResource extends JsonResource
       'lastDoneSchedules' => $this['lastDoneSchedules'],
       'favoriteProviders' => $this['favoriteProviders'],
       'providersClose' => $this['providersClose'],
+      'schedulesProposals' => $this['schedulesProposals'],
       'todaySchedules' => $this['todaySchedules'],
     ];
   }

+ 34 - 0
app/Services/DashboardService.php

@@ -9,6 +9,7 @@ use App\Models\Provider;
 use App\Models\ProviderSpeciality;
 use App\Models\Review;
 use App\Models\Schedule;
+use App\Models\ScheduleProposal;
 use App\Models\Speciality;
 use App\Rules\ScheduleBusinessRules;
 use Illuminate\Support\Facades\Auth;
@@ -182,6 +183,38 @@ class DashboardService
       ->orderBy('schedules.date', 'asc')
       ->get();
 
+      $schedulesProposals = ScheduleProposal::query()
+    ->leftJoin('schedules', 'schedule_proposals.schedule_id', '=', 'schedules.id')
+    ->leftJoin('providers', 'schedule_proposals.provider_id', '=', 'providers.id')
+    ->leftJoin('users', 'providers.user_id', '=', 'users.id')
+
+    ->where('schedules.client_id', $cliente->id)
+    ->where('schedules.schedule_type', 'custom')
+    ->where('schedules.status', 'pending')
+
+    ->orderBy('schedule_proposals.created_at', 'desc')
+
+    ->select([
+        'schedule_proposals.id',
+
+
+        DB::raw("DATE_PART('year', AGE(providers.birth_date)) as idade"),
+        'providers.id as provider_id',
+        'schedules.id as schedule_id',
+        'schedules.date',
+        'schedules.start_time',
+        'schedules.end_time',
+        'schedules.period_type',
+        'schedules.total_amount',
+        'providers.daily_price_8h',
+        'providers.average_rating',
+        'providers.total_services',
+
+        'users.name as provider_name'
+    ])
+
+    ->get();
+
     $todaySchedules = Schedule::with('address:district,address,number,source_id,source,id,address_type')
       ->where('schedules.client_id', $cliente->id)
       ->whereIn('schedules.status', ['accepted', 'paid', 'started', 'finished'])
@@ -224,6 +257,7 @@ class DashboardService
       'favoriteProviders' => $favoriteProviders,
       'providersClose'   => $providersClose,
       'todaySchedules'   => $todaySchedules,
+      'schedulesProposals' => $schedulesProposals,
     ];
   }