Files
sam-manage/app/Models/Documents/DocumentAttachment.php
권혁성 c65d3f49dc feat: 문서 관리 시스템 MNG 관리자 패널 구현 (Phase 2)
- 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>
2026-01-28 21:51:23 +09:00

70 lines
1.7 KiB
PHP

<?php
namespace App\Models\Documents;
use App\Models\File;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class DocumentAttachment extends Model
{
protected $table = 'document_attachments';
// 첨부 유형 상수
public const TYPE_GENERAL = 'general';
public const TYPE_SIGNATURE = 'signature';
public const TYPE_IMAGE = 'image';
public const TYPE_REFERENCE = 'reference';
public const TYPE_LABELS = [
self::TYPE_GENERAL => '일반',
self::TYPE_SIGNATURE => '서명',
self::TYPE_IMAGE => '이미지',
self::TYPE_REFERENCE => '참고자료',
];
protected $fillable = [
'document_id',
'file_id',
'attachment_type',
'description',
'created_by',
];
protected $attributes = [
'attachment_type' => self::TYPE_GENERAL,
];
// =========================================================================
// Relationships
// =========================================================================
public function document(): BelongsTo
{
return $this->belongsTo(Document::class);
}
public function file(): BelongsTo
{
return $this->belongsTo(File::class);
}
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
// =========================================================================
// Accessors
// =========================================================================
public function getTypeLabelAttribute(): string
{
return self::TYPE_LABELS[$this->attachment_type] ?? $this->attachment_type;
}
}