2025-09-05 17:59:34 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Design;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
|
|
class ModelVersion extends Model
|
|
|
|
|
{
|
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
|
|
|
|
protected $table = 'model_versions';
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
2025-11-06 17:45:49 +09:00
|
|
|
'tenant_id', 'model_id', 'version_no', 'status', 'effective_from', 'effective_to', 'notes', 'is_active',
|
2025-09-05 17:59:34 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'is_active' => 'boolean',
|
|
|
|
|
'effective_from' => 'datetime',
|
|
|
|
|
'effective_to' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
|
2025-11-06 17:45:49 +09:00
|
|
|
public function model()
|
|
|
|
|
{
|
2025-09-05 17:59:34 +09:00
|
|
|
return $this->belongsTo(DesignModel::class, 'model_id');
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-06 17:45:49 +09:00
|
|
|
public function bomTemplates()
|
|
|
|
|
{
|
2025-09-05 17:59:34 +09:00
|
|
|
return $this->hasMany(BomTemplate::class, 'model_version_id');
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-06 17:45:49 +09:00
|
|
|
public function scopeReleased($q)
|
|
|
|
|
{
|
2025-09-05 17:59:34 +09:00
|
|
|
return $q->where('status', 'RELEASED');
|
|
|
|
|
}
|
|
|
|
|
}
|