56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\Equipment;
|
||
|
|
|
||
|
|
use App\Traits\ModelTrait;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
class EquipmentInspectionDetail extends Model
|
||
|
|
{
|
||
|
|
use ModelTrait;
|
||
|
|
|
||
|
|
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 static function getNextResult(?string $current): ?string
|
||
|
|
{
|
||
|
|
return match ($current) {
|
||
|
|
null, '' => 'good',
|
||
|
|
'good' => 'bad',
|
||
|
|
'bad' => 'repaired',
|
||
|
|
'repaired' => null,
|
||
|
|
default => 'good',
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function getResultSymbol(?string $result): string
|
||
|
|
{
|
||
|
|
return match ($result) {
|
||
|
|
'good' => '○',
|
||
|
|
'bad' => 'X',
|
||
|
|
'repaired' => '△',
|
||
|
|
default => '',
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|