- Document 관련 모델 4개 생성 (Document, DocumentApproval, DocumentData, DocumentAttachment) - DocumentController 생성 (목록/생성/상세/수정 페이지) - DocumentApiController 생성 (AJAX CRUD 처리) - 문서 관리 뷰 3개 생성 (index, edit, show) - 웹/API 라우트 등록 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Documents;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class DocumentData extends Model
|
|
{
|
|
protected $table = 'document_data';
|
|
|
|
protected $fillable = [
|
|
'document_id',
|
|
'section_id',
|
|
'column_id',
|
|
'row_index',
|
|
'field_key',
|
|
'field_value',
|
|
];
|
|
|
|
protected $casts = [
|
|
'row_index' => 'integer',
|
|
];
|
|
|
|
// =========================================================================
|
|
// Relationships
|
|
// =========================================================================
|
|
|
|
public function document(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Document::class);
|
|
}
|
|
|
|
// =========================================================================
|
|
// Scopes
|
|
// =========================================================================
|
|
|
|
public function scopeForSection($query, int $sectionId)
|
|
{
|
|
return $query->where('section_id', $sectionId);
|
|
}
|
|
|
|
public function scopeForField($query, string $fieldKey)
|
|
{
|
|
return $query->where('field_key', $fieldKey);
|
|
}
|
|
}
|