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:
@@ -32,7 +32,7 @@ class EmployeeSimper extends Model
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
return $this->belongsTo(Employee::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function simperType(): BelongsTo
|
||||
|
||||
@@ -49,7 +49,7 @@ class P2hRecord extends Model
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class);
|
||||
return $this->belongsTo(Employee::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function template(): BelongsTo
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -57,7 +57,7 @@ class UnitSupportTimesheet extends Model
|
||||
|
||||
public function operator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'operator_id');
|
||||
return $this->belongsTo(Employee::class, 'operator_id')->withTrashed();
|
||||
}
|
||||
|
||||
public function createdByUser(): BelongsTo
|
||||
|
||||
@@ -68,7 +68,7 @@ class UnitTransfer extends Model
|
||||
*/
|
||||
public function transporterDriver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'transporter_driver_id');
|
||||
return $this->belongsTo(Employee::class, 'transporter_driver_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,7 +56,7 @@ class VehicleActivity extends Model
|
||||
|
||||
public function driver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'driver_id');
|
||||
return $this->belongsTo(Employee::class, 'driver_id')->withTrashed();
|
||||
}
|
||||
|
||||
public function gate(): BelongsTo
|
||||
|
||||
Reference in New Issue
Block a user