system-locked violation types (alpha & terlambat) + proporsional poin alpha per jam
- Migration: add is_system column to violation_types, mark alpha & terlambat - DestroyType guard: system types cannot be deleted - UpdateType guard: slug tetap walau nama diubah untuk system types - UI: delete button hidden, badge lock untuk system types - Seeder: ViolationTypeDefaultsSeeder untuk fresh deploy - AttendanceController: lookup by slug (alpha/terlambat) instead of fuzzy match - Alpha auto-violation: poin proporsional per jam (round((points/10)*count), min 1) - Terlambat auto-violation: poin fix sesuai jenis (2 poin) - Also handles both A (alpha) and T (terlambat) statuses for auto-violations
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\ViolationCategory;
|
||||
use App\Models\ViolationType;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ViolationTypeDefaultsSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// Cari kategori ringan (ID 1 biasanya)
|
||||
$ringan = ViolationCategory::where('slug', 'ringan')
|
||||
->orWhere('name', 'like', '%ringan%')
|
||||
->first();
|
||||
|
||||
if (!$ringan) {
|
||||
$this->command->warn('Kategori "Ringan" tidak ditemukan. Buat kategori Ringan dulu.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Alpha
|
||||
ViolationType::updateOrCreate(
|
||||
['slug' => 'alpha'],
|
||||
[
|
||||
'name' => 'Alpha - Tidak hadir tanpa keterangan',
|
||||
'category_id' => $ringan->id,
|
||||
'points' => 15,
|
||||
'default_sanction' => 'Peringatan lisan / teguran BK',
|
||||
'description' => 'Pelanggaran otomatis dari sistem presensi ketika siswa tidak hadir tanpa keterangan.',
|
||||
'is_active' => true,
|
||||
'is_system' => true,
|
||||
]
|
||||
);
|
||||
|
||||
// Terlambat
|
||||
ViolationType::updateOrCreate(
|
||||
['slug' => 'terlambat'],
|
||||
[
|
||||
'name' => 'Terlambat',
|
||||
'category_id' => $ringan->id,
|
||||
'points' => 2,
|
||||
'default_sanction' => 'Peringatan lisan',
|
||||
'description' => 'Pelanggaran otomatis dari sistem presensi ketika siswa terlambat.',
|
||||
'is_active' => true,
|
||||
'is_system' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->command->info('System violation types (alpha & terlambat) seeded/updated.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user