- 모델 6개 (Equipment, InspectionTemplate, Inspection, InspectionDetail, Repair, Process) - 서비스 3개 (Equipment, Inspection, Repair) - API 컨트롤러 3개 + FormRequest 4개 - Blade 컨트롤러 + 라우트 등록 - 뷰: 대시보드, 등록대장(CRUD), 일상점검표(캘린더 그리드), 수리이력
63 lines
1.4 KiB
PHP
63 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\SoftDeletes;
|
|
|
|
class EquipmentRepair extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'equipment_id',
|
|
'repair_date',
|
|
'repair_type',
|
|
'repair_hours',
|
|
'description',
|
|
'cost',
|
|
'vendor',
|
|
'repaired_by',
|
|
'memo',
|
|
'created_by',
|
|
'updated_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'repair_date' => 'date',
|
|
'repair_hours' => 'decimal:1',
|
|
'cost' => 'decimal:2',
|
|
];
|
|
|
|
public function equipment(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Equipment::class, 'equipment_id');
|
|
}
|
|
|
|
public function repairer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\User::class, 'repaired_by');
|
|
}
|
|
|
|
public function getRepairTypeLabelAttribute(): string
|
|
{
|
|
return match ($this->repair_type) {
|
|
'internal' => '사내',
|
|
'external' => '외주',
|
|
default => $this->repair_type ?? '-',
|
|
};
|
|
}
|
|
|
|
public function getFormattedCostAttribute(): string
|
|
{
|
|
if (! $this->cost) {
|
|
return '-';
|
|
}
|
|
|
|
return number_format($this->cost).'원';
|
|
}
|
|
}
|