Skip to content

Commit

Permalink
api untuk detail student
Browse files Browse the repository at this point in the history
  • Loading branch information
ArdianS18 committed Nov 13, 2024
1 parent d40df48 commit a0fe5e5
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Contracts/Interfaces/StudentRepairInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ public function groubByCreated(mixed $id): mixed;
public function countByStudent(): mixed;
public function count_approved(mixed $query): mixed;
public function groupByClassroomStudentAndCreated(): mixed;
public function count_repair(mixed $id): mixed;
}
1 change: 1 addition & 0 deletions app/Contracts/Interfaces/StudentViolationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ public function groubByCreated(mixed $id) : mixed;
public function ViolationChart(mixed $year, mixed $month): mixed;
public function count(mixed $query): mixed;
public function countByStudent(): mixed;
public function count_violation(mixed $id): mixed;
}
8 changes: 8 additions & 0 deletions app/Contracts/Repositories/StudentRepairRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,12 @@ public function groupByClassroomStudentAndCreated(): mixed
return $group->groupBy('classroom_student_id');
});
}

public function count_repair(mixed $id): mixed
{
return $this->model->query()
->whereRelation('classroomStudent', 'student_id', $id)
->where('is_approved', '1')
->count();
}
}
9 changes: 9 additions & 0 deletions app/Contracts/Repositories/StudentViolationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,13 @@ public function count(mixed $query): mixed

return $result->count();
}

public function count_violation(mixed $id): mixed
{
return $this->model->query()
->whereRelation('classroomStudent', 'student_id', $id)
->get()
->groupBy('regulation_id')
->count();
}
}
11 changes: 11 additions & 0 deletions app/Http/Controllers/Api/StudentApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,15 @@ public function point_student(User $user)
$student = $this->student->whereUserId($user->id);
return response()->json(['status' => 'success', 'message' => "Berhasil mengirim bukti perbaikan",'code' => 200, 'point' => $student->point]);
}

public function get_detail_profile(User $user)
{
$student = $this->student->whereUserId($user->id);
$repairs = $this->studentRepair->count_repair($student->id);
$violations = $this->studentViolation->count_violation($student->id);
return response()->json(['status' => 'success', 'message' => "Berhasil mengirim bukti perbaikan",'code' => 200, 'data' => [
'repair' => $repairs,
'violation' => $violations,
]]);
}
}
1 change: 1 addition & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
Route::get('student/lesson-schedule/{user}', [StudentApiController::class, 'lessonSchedule']);
Route::get('student/class-student/{user}', [StudentApiController::class, 'class_student']);
Route::get('student/point-student/{user}', [StudentApiController::class, 'point_student']);
Route::get('student/detail-profile/{user}', [StudentApiController::class, 'get_detail_profile']);
Route::get('feedback-active', [PermissionController::class, 'is_active']);

Route::get('student/violation/{user}', [StudentApiController::class, 'violation']);
Expand Down

0 comments on commit a0fe5e5

Please sign in to comment.