|
|
@@ -12,6 +12,7 @@ use App\Models\Review;
|
|
|
use App\Models\Schedule;
|
|
|
use App\Models\ScheduleProposal;
|
|
|
use App\Models\Speciality;
|
|
|
+use App\Models\Notification;
|
|
|
use App\Rules\ScheduleBusinessRules;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
@@ -239,8 +240,26 @@ class DashboardService
|
|
|
->orderBy('schedules.start_time', 'asc')
|
|
|
->get();
|
|
|
|
|
|
+ $notifications = Notification::where('user_id', $user->id)
|
|
|
+ ->orderBy('read', 'asc')
|
|
|
+ ->orderBy('created_at', 'desc')
|
|
|
+ ->limit(10)
|
|
|
+ ->get()
|
|
|
+ ->map(function ($notification) {
|
|
|
+ return [
|
|
|
+ 'id' => $notification->id,
|
|
|
+ 'title' => $notification->title,
|
|
|
+ 'description' => $notification->description,
|
|
|
+ 'time' => $notification->created_at->diffForHumans(),
|
|
|
+ 'read' => $notification->read,
|
|
|
+ 'avatar' => '/icons/avatar.svg',
|
|
|
+ ];
|
|
|
+ });
|
|
|
+
|
|
|
$hasPaymentMethods = ClientPaymentMethod::where('client_id', $cliente->id)->exists();
|
|
|
|
|
|
+
|
|
|
+
|
|
|
return [
|
|
|
'headerBar' => $headerBar,
|
|
|
'summaryInfos' => $summaryInfos,
|
|
|
@@ -251,16 +270,7 @@ class DashboardService
|
|
|
'providersClose' => $providersClose,
|
|
|
'todaySchedules' => $todaySchedules,
|
|
|
'schedulesProposals' => $schedulesProposals,
|
|
|
- 'notifications' => [
|
|
|
- [
|
|
|
- 'id' => 1,
|
|
|
- 'title' => 'Serviço agendado!',
|
|
|
- 'description' => 'Diária confirmada com Marina, 04/11 das 09h30 às 17h30 esse e o cliente',
|
|
|
- 'time' => 'Há 2 minutos',
|
|
|
- 'read' => false,
|
|
|
- 'avatar' => '/icons/avatar.svg'
|
|
|
- ]
|
|
|
- ],
|
|
|
+ 'notifications' => $notifications,
|
|
|
'has_payment_methods' => $hasPaymentMethods,
|
|
|
];
|
|
|
}
|
|
|
@@ -453,6 +463,22 @@ class DashboardService
|
|
|
// ->orderBy('schedules.date', 'asc')
|
|
|
// ->get();
|
|
|
|
|
|
+ $notifications = Notification::where('user_id', $user->id)
|
|
|
+ ->orderBy('read', 'asc')
|
|
|
+ ->orderBy('created_at', 'desc')
|
|
|
+ ->limit(10)
|
|
|
+ ->get()
|
|
|
+ ->map(function ($notification) {
|
|
|
+ return [
|
|
|
+ 'id' => $notification->id,
|
|
|
+ 'title' => $notification->title,
|
|
|
+ 'description' => $notification->description,
|
|
|
+ 'time' => $notification->created_at->diffForHumans(),
|
|
|
+ 'read' => $notification->read,
|
|
|
+ 'avatar' => '/icons/avatar.svg',
|
|
|
+ ];
|
|
|
+ });
|
|
|
+
|
|
|
$customScheduleService = new CustomScheduleService;
|
|
|
|
|
|
$opportunities = $customScheduleService->getAvailableOpportunities($provider->id);
|
|
|
@@ -465,16 +491,7 @@ class DashboardService
|
|
|
'todayServices' => $todayServices,
|
|
|
'nextSchedules' => $nextSchedules,
|
|
|
'opportunities' => $opportunities,
|
|
|
- 'notifications' => [
|
|
|
- [
|
|
|
- 'id' => 1,
|
|
|
- 'title' => 'Serviço agendado!',
|
|
|
- 'description' => 'Diária confirmada com Marina, 04/11 das 09h30 às 17h30, esse e o prestador',
|
|
|
- 'time' => 'Há 2 minutos',
|
|
|
- 'read' => false,
|
|
|
- 'avatar' => '/icons/avatar.svg'
|
|
|
- ]
|
|
|
- ],
|
|
|
+ 'notifications' => $notifications,
|
|
|
];
|
|
|
}
|
|
|
}
|