fix: auto-violasi dari E-Jurnal via ViolationService + notifikasi realtime

Sync controller sekarang pake ViolationService::recordViolation()
biar notifikasi realtime (AppNotification + broadcast event)
dan pengecekan SP threshold tetap jalan untuk data dari E-Jurnal.

ViolationService: recordViolation() & generateSpLetter()
diubah jadi nullable userId supaya bisa dipanggil tanpa user
(0 = system-generated dari sync)
This commit is contained in:
Bro
2026-07-24 13:20:40 +07:00
parent 1ac4a0ef74
commit a5db795eda
2 changed files with 9 additions and 15 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ use Illuminate\Support\Facades\DB;
class ViolationService
{
public function recordViolation(array $data, int $userId): Violation
public function recordViolation(array $data, ?int $userId = null): Violation
{
$violation = DB::transaction(function () use ($data, $userId) {
$violation = Violation::create([
@@ -72,7 +72,7 @@ class ViolationService
return $violation;
}
protected function generateSpLetter(Student $student, SpThreshold $threshold, int $userId): SpLetter
protected function generateSpLetter(Student $student, SpThreshold $threshold, ?int $userId = null): SpLetter
{
$schoolName = Setting::getValue('school_name', 'SMK');
$letterCount = SpLetter::where('sp_threshold_id', $threshold->id)->count() + 1;