Files
sam-manage/app/Models/Equipment/EquipmentInspection.php
김보곤 c84c8894be feat: [database] Equipment 하위 4개 모델 codebridge connection 추가
- EquipmentInspection, EquipmentInspectionDetail, EquipmentInspectionTemplate, EquipmentRepair
- equipments 테이블과 FK 참조 관계 → 동일 DB(codebridge)에서 관리
2026-03-09 20:57:49 +09:00

61 lines
1.5 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
{
protected $connection = 'codebridge';
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',
};
}
}