Files
sam-manage/app/Models/ItemField.php

90 lines
2.0 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* 품목기준 필드 모델
*
* API DB의 item_fields 테이블을 참조합니다.
*/
class ItemField extends Model
{
use BelongsToTenant, SoftDeletes;
protected $fillable = [
'tenant_id',
'group_id',
'field_name',
'field_key',
'field_type',
'order_no',
'is_required',
'default_value',
'placeholder',
'display_condition',
'validation_rules',
'options',
'properties',
'category',
'description',
'is_common',
'is_active',
'is_locked',
'locked_by',
'locked_at',
'created_by',
'updated_by',
'deleted_by',
// 내부용 매핑 컬럼
'source_table',
'source_column',
'storage_type',
'json_path',
];
protected $casts = [
'group_id' => 'integer',
'order_no' => 'integer',
'is_required' => 'boolean',
'is_common' => 'boolean',
'is_active' => 'boolean',
'is_locked' => 'boolean',
'display_condition' => 'array',
'validation_rules' => 'array',
'options' => 'array',
'properties' => 'array',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
'locked_at' => 'datetime',
];
/**
* 시스템 필드 여부 확인 (DB 컬럼과 매핑된 필드)
*/
public function isSystemField(): bool
{
return $this->storage_type === 'column' && ! is_null($this->source_column);
}
/**
* 컬럼 저장 방식 여부 확인
*/
public function isColumnStorage(): bool
{
return $this->storage_type === 'column';
}
/**
* JSON 저장 방식 여부 확인
*/
public function isJsonStorage(): bool
{
return $this->storage_type === 'json';
}
}