- DocumentTemplate 모델 6개 생성 (Template, ApprovalLine, BasicField, Section, SectionItem, Column)
- DocumentTemplateService (list/show) + DocumentTemplateController (index/show)
- GET /v1/document-templates, GET /v1/document-templates/{id} 라우트
- DocumentTemplateApi.php Swagger (7개 스키마, 2개 엔드포인트)
- Document 결재 워크플로우 4개 엔드포인트 활성화 (submit/approve/reject/cancel)
- ApproveRequest, RejectRequest FormRequest 생성
- DocumentApi.php Swagger에 결재 엔드포인트 4개 추가
- Document.template() 참조 경로 수정 (DocumentTemplate → Documents 네임스페이스)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
114 lines
3.0 KiB
PHP
114 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Documents;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* 문서 양식(템플릿) 모델
|
|
*
|
|
* @property int $id
|
|
* @property int $tenant_id
|
|
* @property string $name 양식명
|
|
* @property string $category 분류 (품질, 생산 등)
|
|
* @property string|null $title 문서 제목
|
|
* @property string|null $company_name 회사명
|
|
* @property string|null $company_address 회사 주소
|
|
* @property string|null $company_contact 연락처
|
|
* @property string $footer_remark_label 하단 비고 라벨
|
|
* @property string $footer_judgement_label 하단 판정 라벨
|
|
* @property array|null $footer_judgement_options 판정 옵션 (JSON)
|
|
* @property bool $is_active 활성 여부
|
|
* @property \Carbon\Carbon|null $created_at
|
|
* @property \Carbon\Carbon|null $updated_at
|
|
* @property \Carbon\Carbon|null $deleted_at
|
|
*/
|
|
class DocumentTemplate extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
protected $table = 'document_templates';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'name',
|
|
'category',
|
|
'title',
|
|
'company_name',
|
|
'company_address',
|
|
'company_contact',
|
|
'footer_remark_label',
|
|
'footer_judgement_label',
|
|
'footer_judgement_options',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'footer_judgement_options' => 'array',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
// =========================================================================
|
|
// Relationships
|
|
// =========================================================================
|
|
|
|
/**
|
|
* 결재라인
|
|
*/
|
|
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');
|
|
}
|
|
|
|
// =========================================================================
|
|
// Scopes
|
|
// =========================================================================
|
|
|
|
/**
|
|
* 활성 양식만
|
|
*/
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
|
|
/**
|
|
* 카테고리 필터
|
|
*/
|
|
public function scopeCategory($query, string $category)
|
|
{
|
|
return $query->where('category', $category);
|
|
}
|
|
}
|