- block-editor.blade.php: 3패널 UI (Palette + Canvas + Properties) - Alpine.js blockEditor() 컴포넌트 (CRUD, Undo/Redo, SortableJS) - 기본 Block 6종: heading, paragraph, table, columns, divider, spacer - 폼 필드 Block 7종: text, number, date, select, checkbox, textarea, signature - BlockRendererService: JSON → HTML 렌더링 서비스 - 컨트롤러 분기: builder_type = 'block' → 블록 빌더 뷰 - 라우트 추가: block-create, block-edit - API store/update에 schema JSON 처리 추가 - index 페이지에 블록 빌더 진입 버튼 추가 - 목록에 builder_type 뱃지 표시
112 lines
2.5 KiB
PHP
112 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class DocumentTemplate extends Model
|
|
{
|
|
use BelongsToTenant, HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'name',
|
|
'category',
|
|
'builder_type',
|
|
'title',
|
|
'company_name',
|
|
'company_address',
|
|
'company_contact',
|
|
'footer_remark_label',
|
|
'footer_judgement_label',
|
|
'footer_judgement_options',
|
|
'schema',
|
|
'page_config',
|
|
'is_active',
|
|
'linked_item_ids',
|
|
'linked_process_id',
|
|
];
|
|
|
|
protected $casts = [
|
|
'footer_judgement_options' => 'array',
|
|
'schema' => 'array',
|
|
'page_config' => 'array',
|
|
'linked_item_ids' => 'array',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* 블록 빌더 타입 여부
|
|
*/
|
|
public function isBlockBuilder(): bool
|
|
{
|
|
return $this->builder_type === 'block';
|
|
}
|
|
|
|
/**
|
|
* 레거시 빌더 타입 여부
|
|
*/
|
|
public function isLegacyBuilder(): bool
|
|
{
|
|
return $this->builder_type !== 'block';
|
|
}
|
|
|
|
/**
|
|
* 결재라인
|
|
*/
|
|
public function approvalLines(): HasMany
|
|
{
|
|
return $this->hasMany(DocumentTemplateApprovalLine::class, 'template_id')
|
|
->orderBy('sort_order');
|
|
}
|
|
|
|
/**
|
|
* 기본 필드
|
|
*/
|
|
public function basicFields(): HasMany
|
|
{
|
|
return $this->hasMany(DocumentTemplateBasicField::class, 'template_id')
|
|
->orderBy('sort_order');
|
|
}
|
|
|
|
/**
|
|
* 검사 기준서 섹션
|
|
*/
|
|
public function sections(): HasMany
|
|
{
|
|
return $this->hasMany(DocumentTemplateSection::class, 'template_id')
|
|
->orderBy('sort_order');
|
|
}
|
|
|
|
/**
|
|
* 테이블 컬럼
|
|
*/
|
|
public function columns(): HasMany
|
|
{
|
|
return $this->hasMany(DocumentTemplateColumn::class, 'template_id')
|
|
->orderBy('sort_order');
|
|
}
|
|
|
|
/**
|
|
* 검사 기준서 동적 필드 정의
|
|
*/
|
|
public function sectionFields(): HasMany
|
|
{
|
|
return $this->hasMany(DocumentTemplateSectionField::class, 'template_id')
|
|
->orderBy('sort_order');
|
|
}
|
|
|
|
/**
|
|
* 외부 키 매핑 정의
|
|
*/
|
|
public function links(): HasMany
|
|
{
|
|
return $this->hasMany(DocumentTemplateLink::class, 'template_id')
|
|
->orderBy('sort_order');
|
|
}
|
|
}
|