Files
sam-api/app/Models/Products/CommonCode.php
2026-01-20 20:43:38 +09:00

48 lines
931 B
PHP

<?php
namespace App\Models\Products;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @mixin IdeHelperCommonCode
*/
class CommonCode extends Model
{
use BelongsToTenant, ModelTrait, SoftDeletes;
protected $table = 'common_codes';
protected $fillable = [
'tenant_id',
'code_group',
'code',
'name',
'parent_id',
'attributes',
'description',
'is_active',
'sort_order',
];
protected $casts = [
'attributes' => 'array',
'is_active' => 'boolean',
];
// 관계: 상위 코드
public function parent()
{
return $this->belongsTo(self::class, 'parent_id');
}
// 관계: 하위 코드들
public function children()
{
return $this->hasMany(self::class, 'parent_id');
}
}