36 lines
823 B
PHP
36 lines
823 B
PHP
|
|
<?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 = [
|
||
|
|
'tenant_id','model_id','version_no','status','effective_from','effective_to','notes','is_active',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'is_active' => 'boolean',
|
||
|
|
'effective_from' => 'datetime',
|
||
|
|
'effective_to' => 'datetime',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function model() {
|
||
|
|
return $this->belongsTo(DesignModel::class, 'model_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function bomTemplates() {
|
||
|
|
return $this->hasMany(BomTemplate::class, 'model_version_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function scopeReleased($q) {
|
||
|
|
return $q->where('status', 'RELEASED');
|
||
|
|
}
|
||
|
|
}
|