66
77use App \Filament \Resources \Appointments \AppointmentResource ;
88use App \Filament \Resources \Users \UserResource ;
9+ use App \Filament \Widgets \Components \Stat ;
910use App \Models \Appointment ;
1011use App \Models \Beneficiary ;
1112use App \Models \Intervention ;
1213use App \Models \User ;
1314use App \Services \StatCount ;
1415use Filament \Support \Icons \Heroicon ;
1516use Filament \Widgets \StatsOverviewWidget ;
16- use Filament \Widgets \StatsOverviewWidget \Stat ;
1717
1818class AdminStatsWidget extends StatsOverviewWidget
1919{
@@ -50,40 +50,41 @@ protected function getStats(): array
5050 ];
5151 }
5252
53- /**
54- * @TODO: implement trend
55- */
5653 private function getAppointmentsStat (): Stat
5754 {
5855 $ value = Appointment::select (StatCount::comparedBy ('date ' ))
5956 ->toBase ()
6057 ->first ();
6158
62- return Stat::make (__ ('dashboard.stats.appointments ' ), data_get ($ value , 'current ' ))
59+ $ url = AppointmentResource::getUrl ('index ' );
60+
61+ return Stat::make (__ ('dashboard.stats.appointments ' ))
6362 ->icon (Heroicon::Calendar)
64- ->url (AppointmentResource::getUrl ('index ' ));
63+ ->value ($ value )
64+ ->url ($ url );
6565 }
6666
67- /**
68- * @TODO: implement url
69- */
7067 private function getAllNursesStat (): Stat
7168 {
7269 $ value = User::query ()
7370 ->onlyNurses ()
7471 ->count ();
7572
76- return Stat::make (__ ('dashboard.stats.nurses_total ' ), $ value )
77- ->icon (Heroicon::UserGroup);
78- // ->url(UserResource::getUrl('index'));
73+ $ url = UserResource::getUrl ('index ' );
74+
75+ return Stat::make (__ ('dashboard.stats.nurses_total ' ))
76+ ->icon (Heroicon::UserGroup)
77+ ->value ($ value )
78+ ->url ($ url );
7979 }
8080
8181 private function getAllBeneficiariesStat (): Stat
8282 {
8383 $ value = Beneficiary::count ();
8484
85- return Stat::make (__ ('dashboard.stats.beneficiaries_total ' ), $ value )
86- ->icon (Heroicon::UserGroup);
85+ return Stat::make (__ ('dashboard.stats.beneficiaries_total ' ))
86+ ->icon (Heroicon::UserGroup)
87+ ->value ($ value );
8788 }
8889
8990 private function getActiveBeneficiariesStat (): Stat
@@ -92,13 +93,11 @@ private function getActiveBeneficiariesStat(): Stat
9293 ->onlyActive ()
9394 ->count ();
9495
95- return Stat::make (__ ('dashboard.stats.beneficiaries_active ' ), $ value )
96- ->icon (Heroicon::UserGroup);
96+ return Stat::make (__ ('dashboard.stats.beneficiaries_active ' ))
97+ ->icon (Heroicon::Users)
98+ ->value ($ value );
9799 }
98100
99- /**
100- * @TODO: implement trend
101- */
102101 private function getRealizedServicesStat (): Stat
103102 {
104103 $ value = Intervention::select (StatCount::comparedBy ('closed_at ' ))
@@ -107,7 +106,8 @@ private function getRealizedServicesStat(): Stat
107106 ->toBase ()
108107 ->first ();
109108
110- return Stat::make (__ ('dashboard.stats.services ' ), data_get ($ value , 'current ' ))
111- ->icon (Heroicon::Bolt);
109+ return Stat::make (__ ('dashboard.stats.services ' ))
110+ ->icon (Heroicon::Bolt)
111+ ->trend ($ value );
112112 }
113113}
0 commit comments