feat: penanganan pelanggaran (handling system)
- 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
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class HandlingParticipant extends Model
|
||||
{
|
||||
protected $fillable = ['handling_id', 'user_id', 'role'];
|
||||
|
||||
public function handling(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ViolationHandling::class, 'handling_id');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,14 @@ class User extends Authenticatable
|
||||
{
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class Violation extends Model
|
||||
'description', 'points', 'sanction', 'location',
|
||||
'violation_date', 'violation_time',
|
||||
'is_verified', 'verified_by', 'verified_at',
|
||||
'notes',
|
||||
'notes', 'handling_status', 'handled_at', 'handled_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
@@ -54,4 +54,29 @@ class Violation extends Model
|
||||
{
|
||||
return $this->hasMany(ViolationEvidence::class);
|
||||
}
|
||||
|
||||
public function handlings(): HasMany
|
||||
{
|
||||
return $this->hasMany(ViolationHandling::class);
|
||||
}
|
||||
|
||||
public function handler(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'handled_by');
|
||||
}
|
||||
|
||||
public function isUnhandled(): bool
|
||||
{
|
||||
return $this->handling_status === 'unhandled';
|
||||
}
|
||||
|
||||
public function isInProgress(): bool
|
||||
{
|
||||
return $this->handling_status === 'in_progress';
|
||||
}
|
||||
|
||||
public function isResolved(): bool
|
||||
{
|
||||
return $this->handling_status === 'resolved';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class ViolationHandling extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'violation_id', 'handling_type', 'handling_date',
|
||||
'description', 'location', 'evidence', 'created_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'handling_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function violation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Violation::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function participants(): HasMany
|
||||
{
|
||||
return $this->hasMany(HandlingParticipant::class, 'handling_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user