From 2f0d8395edda93ac4f128761c5161bac89d62b72 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Tue, 31 Mar 2026 19:52:32 +0700 Subject: [PATCH] refactor: remove unused chart and table widgets for assignment completion and attendance ratio --- .../Widgets/MyAssignmentCompletionChart.php | 74 --------------- .../Widgets/MyAttendanceRatioChart.php | 57 ----------- .../Widgets/MyPendingAssignmentsTable.php | 95 ------------------- 3 files changed, 226 deletions(-) delete mode 100644 app/Filament/Widgets/MyAssignmentCompletionChart.php delete mode 100644 app/Filament/Widgets/MyAttendanceRatioChart.php delete mode 100644 app/Filament/Widgets/MyPendingAssignmentsTable.php diff --git a/app/Filament/Widgets/MyAssignmentCompletionChart.php b/app/Filament/Widgets/MyAssignmentCompletionChart.php deleted file mode 100644 index 0e86952..0000000 --- a/app/Filament/Widgets/MyAssignmentCompletionChart.php +++ /dev/null @@ -1,74 +0,0 @@ -user()?->student !== null; - } - - protected function getData(): array - { - $studentId = auth()->user()?->student?->id; - - $baseQuery = Assignment::query() - ->whereHas('assignmentTargets', function (Builder $query) use ($studentId) { - $query->where('student_id', $studentId) - ->orWhereIn('study_group_id', function ($q) use ($studentId) { - $q->select('study_group_id')->from('study_group_members')->where('student_id', $studentId); - }) - ->orWhereIn('study_group_id', function ($q) use ($studentId) { - $q->select('id')->from('study_groups')->where('leader_id', $studentId); - }); - }); - - $submittedCount = (clone $baseQuery)->whereHas('assignmentSubmissions', function (Builder $query) use ($studentId) { - $query->where('student_id', $studentId) - ->orWhereIn('study_group_id', function ($q) use ($studentId) { - $q->select('study_group_id')->from('study_group_members')->where('student_id', $studentId); - }) - ->orWhereIn('study_group_id', function ($q) use ($studentId) { - $q->select('id')->from('study_groups')->where('leader_id', $studentId); - }); - })->count(); - - $totalCount = $baseQuery->count(); - - $notSubmittedCount = $totalCount - $submittedCount; - - return [ - 'datasets' => [ - [ - 'label' => 'Tugas', - 'data' => [$submittedCount, $notSubmittedCount], - 'backgroundColor' => [ - 'rgba(59, 130, 246, 0.8)', // Blue 500 - 'rgba(245, 158, 11, 0.8)', // Amber 500 - ], - 'borderColor' => [ - 'rgba(59, 130, 246, 1)', - 'rgba(245, 158, 11, 1)', - ], - ], - ], - 'labels' => ['Sudah Dikerjakan', 'Belum Dikerjakan'], - ]; - } - - protected function getType(): string - { - return 'doughnut'; - } -} diff --git a/app/Filament/Widgets/MyAttendanceRatioChart.php b/app/Filament/Widgets/MyAttendanceRatioChart.php deleted file mode 100644 index 9e4b083..0000000 --- a/app/Filament/Widgets/MyAttendanceRatioChart.php +++ /dev/null @@ -1,57 +0,0 @@ -user()?->student !== null; - } - - protected function getData(): array - { - $studentId = auth()->user()?->student?->id; - - $presentCount = Attendance::where('student_id', $studentId) - ->whereNotNull('attended_at') - ->count(); - - $absentCount = Attendance::where('student_id', $studentId) - ->whereNull('attended_at') - ->where('date', '<=', today()) - ->count(); - - return [ - 'datasets' => [ - [ - 'label' => 'Presensi', - 'data' => [$presentCount, $absentCount], - 'backgroundColor' => [ - 'rgba(16, 185, 129, 0.8)', // Emerald 500 - 'rgba(244, 63, 94, 0.8)', // Rose 500 - ], - 'borderColor' => [ - 'rgba(16, 185, 129, 1)', - 'rgba(244, 63, 94, 1)', - ], - ], - ], - 'labels' => ['Hadir', 'Tidak / Belum Hadir'], - ]; - } - - protected function getType(): string - { - return 'doughnut'; - } -} diff --git a/app/Filament/Widgets/MyPendingAssignmentsTable.php b/app/Filament/Widgets/MyPendingAssignmentsTable.php deleted file mode 100644 index b8900f9..0000000 --- a/app/Filament/Widgets/MyPendingAssignmentsTable.php +++ /dev/null @@ -1,95 +0,0 @@ -user()?->student !== null; - } - - public function table(Table $table): Table - { - $studentId = auth()->user()?->student?->id; - - return $table - ->query( - Assignment::query() - ->whereHas('assignmentTargets', function (Builder $query) use ($studentId) { - $query->where('student_id', $studentId) - ->orWhereIn('study_group_id', function ($q) use ($studentId) { - $q->select('study_group_id') - ->from('study_group_members') - ->where('student_id', $studentId); - }) - ->orWhereIn('study_group_id', function ($q) use ($studentId) { - $q->select('id') - ->from('study_groups') - ->where('leader_id', $studentId); - }); - }) - ->whereDoesntHave('assignmentSubmissions', function (Builder $query) use ($studentId) { - $query->where('student_id', $studentId) - ->orWhereIn('study_group_id', function ($q) use ($studentId) { - $q->select('study_group_id') - ->from('study_group_members') - ->where('student_id', $studentId); - }) - ->orWhereIn('study_group_id', function ($q) use ($studentId) { - $q->select('id') - ->from('study_groups') - ->where('leader_id', $studentId); - }); - }) - ->where('due_date', '>=', now()) - ->orderBy('due_date', 'asc') - ) - ->columns([ - TextColumn::make('title') - ->label('Judul Tugas') - ->searchable() - ->sortable() - ->wrap(), - - TextColumn::make('course.name') - ->label('Mata Kuliah') - ->searchable() - ->sortable() - ->wrap(), - - TextColumn::make('type') - ->label('Jenis') - ->badge(), - - TextColumn::make('due_date') - ->label('Tenggat Waktu') - ->dateTime('d M Y H:i') - ->sortable() - ->color(fn (Assignment $record) => $record->due_date < now()->addDays(2) ? 'danger' : 'warning'), - ]) - ->recordActions([ - Action::make('kerjakan') - ->label('Lihat Detail & Kerjakan') - ->url(fn (Assignment $record): string => '/admin/learning/assignments/'.$record->id.'/submit') - ->icon('heroicon-m-arrow-top-right-on-square') - ->button() - ->color('primary'), - ]) - ->emptyStateHeading('Tidak Ada Tugas') - ->emptyStateDescription('Semua tugas telah diselesaikan atau tidak ada tugas mendatang.'); - } -}