47 lines
929 B
PHP
47 lines
929 B
PHP
<?php
|
|
|
|
namespace App\Models\Products;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use App\Traits\BelongsToTenant;
|
|
use App\Traits\ModelTrait;
|
|
/**
|
|
* @mixin IdeHelperCommonCode
|
|
*/
|
|
class CommonCode extends Model
|
|
{
|
|
use SoftDeletes, BelongsToTenant, ModelTrait;
|
|
|
|
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');
|
|
}
|
|
}
|