fix : 모델, BOM 구성 수정
- 설계용 모델, BOM 기능 추가
This commit is contained in:
29
app/Models/Design/BomTemplate.php
Normal file
29
app/Models/Design/BomTemplate.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Design;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class BomTemplate extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'bom_templates';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id','model_version_id','name','is_primary','notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_primary' => 'boolean',
|
||||
];
|
||||
|
||||
public function modelVersion() {
|
||||
return $this->belongsTo(ModelVersion::class, 'model_version_id');
|
||||
}
|
||||
|
||||
public function items() {
|
||||
return $this->hasMany(BomTemplateItem::class, 'bom_template_id');
|
||||
}
|
||||
}
|
||||
23
app/Models/Design/BomTemplateItem.php
Normal file
23
app/Models/Design/BomTemplateItem.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Design;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BomTemplateItem extends Model
|
||||
{
|
||||
protected $table = 'bom_template_items';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id','bom_template_id','ref_type','ref_id','qty','waste_rate','uom_id','notes','sort_order',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'qty' => 'decimal:6',
|
||||
'waste_rate' => 'decimal:6',
|
||||
];
|
||||
|
||||
public function template() {
|
||||
return $this->belongsTo(BomTemplate::class, 'bom_template_id');
|
||||
}
|
||||
}
|
||||
26
app/Models/Design/DesignModel.php
Normal file
26
app/Models/Design/DesignModel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Design;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class DesignModel extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'models';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id','code','name','category_id','lifecycle','description','is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
// 관계: 모델은 여러 버전을 가짐
|
||||
public function versions() {
|
||||
return $this->hasMany(ModelVersion::class, 'model_id');
|
||||
}
|
||||
}
|
||||
35
app/Models/Design/ModelVersion.php
Normal file
35
app/Models/Design/ModelVersion.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user