first commit

This commit is contained in:
Saufi
2026-06-24 20:32:14 +08:00
commit 10fb30ad69
201 changed files with 21356 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Activitylog\Support\LogOptions;
use Spatie\Activitylog\Models\Concerns\LogsActivity;
class ReportingCycle extends Model
{
use HasFactory, LogsActivity;
protected $fillable = [
'renewal_year',
'reporting_year',
'period_start',
'period_end',
'cut_off_date',
'licence_period_year',
'checklist_template_id',
'status',
'catatan',
];
protected function casts(): array
{
return [
'renewal_year' => 'integer',
'reporting_year' => 'integer',
'period_start' => 'date',
'period_end' => 'date',
'cut_off_date' => 'date',
'licence_period_year' => 'integer',
];
}
/**
* Peraturan perniagaan: tahun pelaporan = tahun pembaharuan - 2.
* Cth: pembaharuan 2028 => pelaporan 2026.
*/
public static function reportingYearFor(int $renewalYear): int
{
return $renewalYear - 2;
}
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logOnly(['renewal_year', 'reporting_year', 'cut_off_date', 'status'])
->logOnlyDirty()
->dontLogEmptyChanges()
->useLogName('kitaran_pelaporan');
}
public function checklistTemplate(): BelongsTo
{
return $this->belongsTo(ChecklistTemplate::class);
}
public function submissions(): HasMany
{
return $this->hasMany(Submission::class);
}
public function scopeAktif($query)
{
return $query->where('status', 'aktif');
}
public function isOverdue(): bool
{
return $this->cut_off_date && now()->startOfDay()->gt($this->cut_off_date);
}
}