Files
sam-manage/app/Models/Equipment/EquipmentInspection.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

59 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',
'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',
};
}
}