@php $bulanIni = \carbon\Carbon::now()->translatedFormat('F'); $totalBerita = \Modules\Berita\Models\Berita::count(); // Menghitung total reporter dengan role 'reporter' menggunakan Spatie $totalReporter = \App\Models\User::role('reporter')->count(); // Menghitung dan mengambil nama top reporter $topReporter = \Modules\Berita\Models\Berita::select('user_id') ->groupBy('user_id') ->orderByRaw('COUNT(*) DESC') ->limit(1) ->with('user') // Pastikan relasi user didefinisikan di model Berita ->first(); // Mengambil nama reporter teratas $topReporterName = $topReporter ? $topReporter->user->name : 'Tidak ada reporter'; // Menghitung jumlah berita oleh reporter teratas $sumBeritabyreporter = $topReporter ? \Modules\Berita\Models\Berita::where('user_id', $topReporter->user_id)->count() : 0; // Menghitung berita bulan ini $BeritaBulanIni = \Modules\Berita\Models\Berita::whereMonth('created_at', now()->month) ->whereYear('created_at', now()->year) ->count(); @endphp