- 테이블 3개: bad_debts, bad_debt_documents, bad_debt_memos - 모델 3개: BadDebt, BadDebtDocument, BadDebtMemo - BadDebtService: CRUD, 요약 통계, 서류/메모 관리 - API 엔드포인트 11개 (목록, 등록, 상세, 수정, 삭제, 토글, 서류/메모 CRUD) - Swagger 문서 작성 완료
59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models\BadDebts;
|
|
|
|
use App\Models\Commons\File;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class BadDebtDocument extends Model
|
|
{
|
|
protected $fillable = [
|
|
'bad_debt_id',
|
|
'document_type',
|
|
'file_id',
|
|
];
|
|
|
|
/**
|
|
* 서류 유형 상수
|
|
*/
|
|
public const TYPE_BUSINESS_LICENSE = 'business_license';
|
|
|
|
public const TYPE_TAX_INVOICE = 'tax_invoice';
|
|
|
|
public const TYPE_ADDITIONAL = 'additional';
|
|
|
|
/**
|
|
* 서류 유형 목록
|
|
*/
|
|
public const DOCUMENT_TYPES = [
|
|
self::TYPE_BUSINESS_LICENSE => '사업자등록증',
|
|
self::TYPE_TAX_INVOICE => '세금계산서',
|
|
self::TYPE_ADDITIONAL => '추가서류',
|
|
];
|
|
|
|
/**
|
|
* 악성채권 관계
|
|
*/
|
|
public function badDebt(): BelongsTo
|
|
{
|
|
return $this->belongsTo(BadDebt::class);
|
|
}
|
|
|
|
/**
|
|
* 파일 관계
|
|
*/
|
|
public function file(): BelongsTo
|
|
{
|
|
return $this->belongsTo(File::class);
|
|
}
|
|
|
|
/**
|
|
* 서류 유형 라벨 속성
|
|
*/
|
|
public function getDocumentTypeLabelAttribute(): string
|
|
{
|
|
return self::DOCUMENT_TYPES[$this->document_type] ?? $this->document_type;
|
|
}
|
|
}
|