2025-07-23 15:41:01 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Products;
|
|
|
|
|
|
2025-07-29 17:20:44 +09:00
|
|
|
use App\Models\Commons\Tag;
|
2025-07-23 15:41:01 +09:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
2025-08-21 09:50:15 +09:00
|
|
|
/**
|
|
|
|
|
* @mixin IdeHelperPart
|
|
|
|
|
*/
|
2025-07-23 15:41:01 +09:00
|
|
|
class Part extends Model
|
|
|
|
|
{
|
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
2025-11-06 17:45:49 +09:00
|
|
|
protected $fillable = ['tenant_id', 'code', 'name', 'category_id', 'part_type_id', 'unit', 'attributes', 'description', 'is_active'];
|
|
|
|
|
|
|
|
|
|
public function category()
|
|
|
|
|
{
|
2025-07-23 15:41:01 +09:00
|
|
|
return $this->belongsTo(CommonCode::class, 'category_id');
|
|
|
|
|
}
|
2025-11-06 17:45:49 +09:00
|
|
|
|
|
|
|
|
public function partType()
|
|
|
|
|
{
|
2025-07-23 15:41:01 +09:00
|
|
|
return $this->belongsTo(CommonCode::class, 'part_type_id');
|
|
|
|
|
}
|
2025-07-29 17:20:44 +09:00
|
|
|
|
|
|
|
|
// 태그 목록 (N:M, 폴리모픽)
|
|
|
|
|
public function tags()
|
|
|
|
|
{
|
|
|
|
|
return $this->morphToMany(Tag::class, 'taggable');
|
|
|
|
|
}
|
2025-07-23 15:41:01 +09:00
|
|
|
}
|