- 동적 필드/연결 모델 추가 (SectionField, Link, LinkValue, Preset) - 통합 검색 API (SourceTableSearchController) - items/processes/lots/users - 템플릿 편집 UI: 소스 테이블 드롭다운 + datalist 검색/선택 - 문서 작성/인쇄/상세 뷰: getFieldValue() 기반 동적 렌더링 - DocumentTemplateApiController: source_table 기반 저장/복제 - DocumentController: sectionFields/links eager loading 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class DocumentTemplateSectionItem extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'section_id',
|
|
'category',
|
|
'item',
|
|
'standard',
|
|
'tolerance',
|
|
'standard_criteria',
|
|
'method',
|
|
'measurement_type',
|
|
'frequency_n',
|
|
'frequency_c',
|
|
'frequency',
|
|
'regulation',
|
|
'field_values',
|
|
'sort_order',
|
|
];
|
|
|
|
protected $casts = [
|
|
'tolerance' => 'array',
|
|
'standard_criteria' => 'array',
|
|
'field_values' => 'array',
|
|
'sort_order' => 'integer',
|
|
'frequency_n' => 'integer',
|
|
'frequency_c' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* field_values 우선, 없으면 기존 컬럼 fallback
|
|
*/
|
|
public function getFieldValue(string $key): mixed
|
|
{
|
|
if (! empty($this->field_values) && array_key_exists($key, $this->field_values)) {
|
|
return $this->field_values[$key];
|
|
}
|
|
|
|
return $this->attributes[$key] ?? null;
|
|
}
|
|
|
|
public function section(): BelongsTo
|
|
{
|
|
return $this->belongsTo(DocumentTemplateSection::class, 'section_id');
|
|
}
|
|
}
|