Files
sam-manage/app/Models/Equipment/EquipmentInspectionTemplate.php
김보곤 beecf0851e feat: [equipment] 다중 점검주기 + 정/부 담당자 체계 구현
- InspectionCycle enum: 6종 점검주기 상수, 열 라벨, check_date 계산
- Equipment 모델: subManager 관계, canInspect() 권한 체크
- Template/Inspection 모델: inspection_cycle fillable 추가
- EquipmentInspectionService: 주기별 점검 조회/토글/권한 체크
- 점검표 UI: 주기 탭, 동적 필터(월/연도), 주기별 그리드 열
- 점검항목 템플릿: 주기별 탭 그룹핑, 모달에 주기 선택
- 설비 등록/수정/상세: 부 담당자 필드 추가
- 권한 없는 장비 셀 비활성(cursor-not-allowed, opacity-50)
2026-02-28 12:37:37 +09:00

55 lines
1.2 KiB
PHP

<?php
namespace App\Models\Equipment;
use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class EquipmentInspectionTemplate extends Model
{
use BelongsToTenant;
protected $fillable = [
'tenant_id',
'equipment_id',
'inspection_cycle',
'item_no',
'check_point',
'check_item',
'check_timing',
'check_frequency',
'check_method',
'sort_order',
'is_active',
];
protected $casts = [
'is_active' => 'boolean',
];
public function equipment(): BelongsTo
{
return $this->belongsTo(Equipment::class, 'equipment_id');
}
public function scopeActive($query)
{
return $query->where('is_active', true);
}
public function scopeByCycle($query, string $cycle)
{
return $query->where('inspection_cycle', $cycle);
}
public function getTimingLabelAttribute(): string
{
return match ($this->check_timing) {
'operating' => '가동 중',
'stopped' => '정지 시',
default => $this->check_timing ?? '-',
};
}
}