43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Products;
|
|
|
|
use App\Models\Commons\File;
|
|
use App\Models\Commons\Tag;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* @mixin IdeHelperBom
|
|
*/
|
|
class Bom extends Model
|
|
{
|
|
use SoftDeletes;
|
|
protected $fillable = ['tenant_id','product_id','code','name','category_id','attributes','description','is_default','is_active','image_file_id'];
|
|
|
|
public function product() {
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
public function category() {
|
|
return $this->belongsTo(CommonCode::class, 'category_id');
|
|
}
|
|
public function items() {
|
|
return $this->hasMany(BomItem::class);
|
|
}
|
|
public function image() {
|
|
return $this->belongsTo(File::class, 'image_file_id');
|
|
}
|
|
|
|
// 파일 목록 (N:M, 폴리모픽)
|
|
public function files()
|
|
{
|
|
return $this->morphMany(File::class, 'fileable');
|
|
}
|
|
|
|
// 태그 목록 (N:M, 폴리모픽)
|
|
public function tags()
|
|
{
|
|
return $this->morphToMany(Tag::class, 'taggable');
|
|
}
|
|
}
|