Files
sam-manage/app/Models/Equipment/EquipmentInspectionDetail.php
김보곤 4115bbd7db feat: [equipment] 설비관리 모듈 구현
- 모델 6개 (Equipment, InspectionTemplate, Inspection, InspectionDetail, Repair, Process)
- 서비스 3개 (Equipment, Inspection, Repair)
- API 컨트롤러 3개 + FormRequest 4개
- Blade 컨트롤러 + 라우트 등록
- 뷰: 대시보드, 등록대장(CRUD), 일상점검표(캘린더 그리드), 수리이력
2026-02-25 19:39:59 +09:00

63 lines
1.4 KiB
PHP

<?php
namespace App\Models\Equipment;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class EquipmentInspectionDetail extends Model
{
protected $fillable = [
'inspection_id',
'template_item_id',
'check_date',
'result',
'note',
];
protected $casts = [
'check_date' => 'date',
];
public function inspection(): BelongsTo
{
return $this->belongsTo(EquipmentInspection::class, 'inspection_id');
}
public function templateItem(): BelongsTo
{
return $this->belongsTo(EquipmentInspectionTemplate::class, 'template_item_id');
}
public function getResultSymbolAttribute(): string
{
return match ($this->result) {
'good' => '○',
'bad' => 'X',
'repaired' => '△',
default => '',
};
}
public function getResultColorAttribute(): string
{
return match ($this->result) {
'good' => 'text-green-600',
'bad' => 'text-red-600',
'repaired' => 'text-yellow-600',
default => 'text-gray-400',
};
}
public static function getNextResult(?string $current): ?string
{
return match ($current) {
null, '' => 'good',
'good' => 'bad',
'bad' => 'repaired',
'repaired' => null,
default => 'good',
};
}
}