diff --git a/app/Filament/Widgets/JournalistMetricsStats.php b/app/Filament/Widgets/JournalistMetricsStats.php new file mode 100644 index 0000000..9cee29a --- /dev/null +++ b/app/Filament/Widgets/JournalistMetricsStats.php @@ -0,0 +1,31 @@ + 0 ? round($totalJournalists / $totalMedia, 1) : 0; + + return [ + Stat::make('Rata-rata Jurnalis / Media', $average) + ->description('Rasio sebaran jurnalis') + ->descriptionIcon(Heroicon::Users) + ->color('primary'), + ]; + } +} diff --git a/app/Filament/Widgets/JournalistRegistrationChart.php b/app/Filament/Widgets/JournalistRegistrationChart.php new file mode 100644 index 0000000..bf4e772 --- /dev/null +++ b/app/Filament/Widgets/JournalistRegistrationChart.php @@ -0,0 +1,47 @@ +select( + DB::raw('COUNT(*) as count'), + DB::raw("DATE_FORMAT(created_at, '%Y-%m') as month") + ) + ->where('created_at', '>=', now()->subMonths(6)) + ->groupBy('month') + ->orderBy('month') + ->get(); + + return [ + 'datasets' => [ + [ + 'label' => 'Jurnalis Baru', + 'data' => $data->pluck('count')->toArray(), + 'fill' => 'start', + 'borderColor' => '#6366F1', + 'backgroundColor' => 'rgba(99, 102, 241, 0.1)', + ], + ], + 'labels' => $data->pluck('month')->map(fn ($m) => \Carbon\Carbon::createFromFormat('Y-m', $m)->translatedFormat('M Y'))->toArray(), + ]; + } + + protected function getType(): string + { + return 'line'; + } +} diff --git a/app/Filament/Widgets/JournalistUkwChart.php b/app/Filament/Widgets/JournalistUkwChart.php new file mode 100644 index 0000000..2c40614 --- /dev/null +++ b/app/Filament/Widgets/JournalistUkwChart.php @@ -0,0 +1,43 @@ +where('ukw_certificate', '!=', '') + ->count(); + + $notCertified = Journalist::where(function ($query) { + $query->whereNull('ukw_certificate') + ->orWhere('ukw_certificate', ''); + })->count(); + + return [ + 'datasets' => [ + [ + 'label' => 'Jumlah Jurnalis', + 'data' => [$certified, $notCertified], + 'backgroundColor' => ['#10B981', '#EF4444'], + ], + ], + 'labels' => ['Sudah Sertifikasi UKW', 'Belum Sertifikasi UKW'], + ]; + } + + protected function getType(): string + { + return 'doughnut'; + } +}