- Migration: handling_status, handled_at, handled_by ke violations - Migration: tabel violation_handlings, handling_participants - Model: ViolationHandling, HandlingParticipant + relasi - Routes: storeHandling, resolveHandling, destroyHandling, calendar data - ViolationController: CRUD penanganan + filter status handling - DashboardController: data handling stats + calendar endpoint - Dashboard view: kalender pelanggaran interaktif (Alpine.js) - Violations index: filter status penanganan + kolom status - Violations show: stat card penanganan + timeline + modal tambah - Menambahkan handling_status filter di index
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasFactory, Notifiable;
|
|
|
|
protected $fillable = [
|
|
'name', 'username', 'email', 'password', 'role', 'is_active',
|
|
];
|
|
|
|
protected $hidden = ['password', 'remember_token'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
'is_active' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function isAdmin(): bool { return $this->role === 'admin'; }
|
|
public function isBK(): bool { return $this->role === 'bk'; }
|
|
public function isWaliKelas(): bool { return $this->role === 'wali_kelas'; }
|
|
|
|
public function recordedViolations()
|
|
{
|
|
return $this->hasMany(Violation::class, 'recorded_by');
|
|
}
|
|
|
|
public function appNotifications()
|
|
{
|
|
return $this->hasMany(AppNotification::class, 'user_id');
|
|
}
|
|
|
|
public function handlingParticipants()
|
|
{
|
|
return $this->hasMany(HandlingParticipant::class);
|
|
}
|
|
|
|
public function createdHandlings()
|
|
{
|
|
return $this->hasMany(ViolationHandling::class, 'created_by');
|
|
}
|
|
}
|