fix(hse): allow soft deleting employee without losing operational history, fix simper checklist badge overflow, and enforce valid future expiry date

This commit is contained in:
Ray1111-aa
2026-11-02 14:35:24 +07:00
parent 23377631b3
commit 008e5f6b9d
12 changed files with 302 additions and 58 deletions
+29
View File
@@ -98,6 +98,7 @@ class SimperType extends Model
protected $appends = [
'scopes',
'category_scope_display',
'short_scope_display',
];
/**
@@ -184,6 +185,34 @@ class SimperType extends Model
return implode(', ', $formatted);
}
/**
* Teks ringkas pendek untuk badge di UI (maksimal 2 kategori + counter jika panjang).
*/
public function getShortScopeDisplayAttribute(): string
{
$scopes = $this->scopes;
if (empty($scopes) || in_array(self::SCOPE_ALL, $scopes, true)) {
return 'UNIVERSAL';
}
if (count($scopes) === 1 && $scopes[0] === self::SCOPE_LIGHT_VEHICLE) {
return 'LV';
}
$formatted = array_map(function ($s) {
if ($s === self::SCOPE_LIGHT_VEHICLE) return 'LV';
if ($s === self::SCOPE_ALL) return 'Universal';
return strtoupper(str_replace('_', ' ', $s));
}, $scopes);
if (count($formatted) > 2) {
return $formatted[0] . ', ' . $formatted[1] . ' (+' . (count($formatted) - 2) . ')';
}
return implode(', ', $formatted);
}
public function employeeSimpers(): HasMany
{
return $this->hasMany(EmployeeSimper::class);