69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Modules\IndustrialEngineering\Models;
|
|
|
|
use App\Transaction;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class SerializedUnit extends Model
|
|
{
|
|
use BelongsToBusiness;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'ie_serialized_units';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'build_started_at' => 'date',
|
|
'build_completed_at' => 'date',
|
|
'as_built_snapshot' => 'array',
|
|
];
|
|
|
|
public function releasePackage()
|
|
{
|
|
return $this->belongsTo(ReleasePackage::class, 'release_package_id');
|
|
}
|
|
|
|
public function workOrder()
|
|
{
|
|
return $this->belongsTo(ManufacturingWorkOrder::class, 'work_order_id');
|
|
}
|
|
|
|
public function lineRevision()
|
|
{
|
|
return $this->belongsTo(LineRevision::class, 'line_revision_id');
|
|
}
|
|
|
|
public function serialRegistry()
|
|
{
|
|
return $this->belongsTo(SerialRegistry::class, 'serial_registry_id');
|
|
}
|
|
|
|
public function components()
|
|
{
|
|
return $this->hasMany(SerializedUnitComponent::class, 'serialized_unit_id');
|
|
}
|
|
|
|
public function rootComponents()
|
|
{
|
|
return $this->hasMany(SerializedUnitComponent::class, 'serialized_unit_id')->whereNull('parent_component_id');
|
|
}
|
|
|
|
public function genealogyEvents()
|
|
{
|
|
return $this->hasMany(BuildGenealogyEvent::class, 'serialized_unit_id');
|
|
}
|
|
|
|
public function installedAsset()
|
|
{
|
|
return $this->hasOne(CustomerInstalledAsset::class, 'serialized_unit_id');
|
|
}
|
|
|
|
public function productionTransaction()
|
|
{
|
|
return $this->belongsTo(Transaction::class, 'production_transaction_id');
|
|
}
|
|
}
|