59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\IndustrialEngineering\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class SerializedUnitComponent extends Model
|
|
{
|
|
use BelongsToBusiness;
|
|
|
|
protected $table = 'ie_serialized_unit_components';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'decimal:4',
|
|
'manufactured_at' => 'date',
|
|
'installed_at' => 'date',
|
|
'warranty_starts_at' => 'date',
|
|
'warranty_expires_at' => 'date',
|
|
'metadata' => 'array',
|
|
];
|
|
|
|
public function serializedUnit()
|
|
{
|
|
return $this->belongsTo(SerializedUnit::class, 'serialized_unit_id');
|
|
}
|
|
|
|
public function parentComponent()
|
|
{
|
|
return $this->belongsTo(SerializedUnitComponent::class, 'parent_component_id');
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
return $this->hasMany(SerializedUnitComponent::class, 'parent_component_id');
|
|
}
|
|
|
|
public function bomLine()
|
|
{
|
|
return $this->belongsTo(BomLine::class, 'bom_line_id');
|
|
}
|
|
|
|
public function itemMaster()
|
|
{
|
|
return $this->belongsTo(ItemMaster::class, 'item_master_id');
|
|
}
|
|
|
|
public function serialRegistry()
|
|
{
|
|
return $this->belongsTo(SerialRegistry::class, 'serial_registry_id');
|
|
}
|
|
|
|
public function supplier()
|
|
{
|
|
return $this->belongsTo(Supplier::class, 'supplier_id');
|
|
}
|
|
}
|