93 lines
2.2 KiB
PHP
93 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class EquipmentPart extends Model
|
|
{
|
|
protected $table = 'maintenance_equipment_parts';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'equipment_id',
|
|
'parent_id',
|
|
'spare_part_id',
|
|
'part_catalog_id',
|
|
'part_name',
|
|
'part_code',
|
|
'quantity',
|
|
'unit',
|
|
'part_type',
|
|
'is_consumable',
|
|
'is_critical',
|
|
'responsibility',
|
|
'responsibility_party_name',
|
|
'warranty_status',
|
|
'warranty_provider',
|
|
'warranty_expires_at',
|
|
'installed_by',
|
|
'installer_name',
|
|
'expected_replacement_date',
|
|
'replacement_interval_days',
|
|
'last_replaced_at',
|
|
'replacement_quality_grade',
|
|
'damage_action',
|
|
'damage_service_list',
|
|
'multi_year_service_plan',
|
|
'health_percentage',
|
|
'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'decimal:3',
|
|
'is_critical' => 'boolean',
|
|
'is_consumable' => 'boolean',
|
|
'warranty_expires_at' => 'date',
|
|
'expected_replacement_date' => 'date',
|
|
'last_replaced_at' => 'date',
|
|
'health_percentage' => 'decimal:2',
|
|
'damage_service_list' => 'array',
|
|
'multi_year_service_plan' => 'array',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{ }
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function equipment()
|
|
{
|
|
return $this->belongsTo(Equipment::class, 'equipment_id');
|
|
}
|
|
|
|
public function parent()
|
|
{
|
|
return $this->belongsTo(self::class, 'parent_id');
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id');
|
|
}
|
|
|
|
public function sparePart()
|
|
{
|
|
return $this->belongsTo(SparePart::class, 'spare_part_id');
|
|
}
|
|
|
|
public function partCatalog()
|
|
{
|
|
return $this->belongsTo(PartCatalog::class, 'part_catalog_id');
|
|
}
|
|
|
|
public function documents()
|
|
{
|
|
return $this->morphMany(AssetDocument::class, 'documentable')->orderBy('sort_order');
|
|
}
|
|
}
|