Files
sam-manage/app/Models/Equipment/EquipmentInspection.php
김보곤 cd0afb9c6e 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:59 +09:00

60 lines
1.4 KiB
PHP

<?php
namespace App\Models\Equipment;
use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class EquipmentInspection extends Model
{
use BelongsToTenant;
protected $fillable = [
'tenant_id',
'equipment_id',
'inspection_cycle',
'year_month',
'overall_judgment',
'inspector_id',
'repair_note',
'issue_note',
'created_by',
'updated_by',
];
public function equipment(): BelongsTo
{
return $this->belongsTo(Equipment::class, 'equipment_id');
}
public function inspector(): BelongsTo
{
return $this->belongsTo(\App\Models\User::class, 'inspector_id');
}
public function details(): HasMany
{
return $this->hasMany(EquipmentInspectionDetail::class, 'inspection_id');
}
public function getJudgmentLabelAttribute(): string
{
return match ($this->overall_judgment) {
'OK' => '양호',
'NG' => '이상',
default => '-',
};
}
public function getJudgmentColorAttribute(): string
{
return match ($this->overall_judgment) {
'OK' => 'bg-green-100 text-green-800',
'NG' => 'bg-red-100 text-red-800',
default => 'bg-gray-100 text-gray-800',
};
}
}