feat: [QMS] 1일차 기준/매뉴얼 심사 백엔드 구현 (Phase 2)
- 마이그레이션: audit_checklists, audit_checklist_categories, audit_checklist_items, audit_standard_documents (4테이블)
- 모델 4개: AuditChecklist, AuditChecklistCategory, AuditChecklistItem, AuditStandardDocument
- AuditChecklistService: CRUD, 완료처리, 항목 토글(lockForUpdate), 기준 문서 연결/해제, 카테고리+항목 일괄 동기화
- AuditChecklistController: 9개 엔드포인트
- FormRequest 2개: Store(카테고리+항목 중첩 검증), Update
- 라우트 9개 등록 (/api/v1/qms/checklists, checklist-items)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:41:20 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Qualitys;
|
|
|
|
|
|
2026-03-10 17:55:00 +09:00
|
|
|
use App\Traits\Auditable;
|
|
|
|
|
use App\Traits\BelongsToTenant;
|
feat: [QMS] 1일차 기준/매뉴얼 심사 백엔드 구현 (Phase 2)
- 마이그레이션: audit_checklists, audit_checklist_categories, audit_checklist_items, audit_standard_documents (4테이블)
- 모델 4개: AuditChecklist, AuditChecklistCategory, AuditChecklistItem, AuditStandardDocument
- AuditChecklistService: CRUD, 완료처리, 항목 토글(lockForUpdate), 기준 문서 연결/해제, 카테고리+항목 일괄 동기화
- AuditChecklistController: 9개 엔드포인트
- FormRequest 2개: Store(카테고리+항목 중첩 검증), Update
- 라우트 9개 등록 (/api/v1/qms/checklists, checklist-items)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:41:20 +09:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
|
|
class AuditChecklist extends Model
|
|
|
|
|
{
|
|
|
|
|
use Auditable, BelongsToTenant, SoftDeletes;
|
|
|
|
|
|
|
|
|
|
protected $table = 'audit_checklists';
|
|
|
|
|
|
|
|
|
|
const STATUS_DRAFT = 'draft';
|
|
|
|
|
|
|
|
|
|
const STATUS_IN_PROGRESS = 'in_progress';
|
|
|
|
|
|
|
|
|
|
const STATUS_COMPLETED = 'completed';
|
|
|
|
|
|
|
|
|
|
const TYPE_STANDARD_MANUAL = 'standard_manual';
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'tenant_id',
|
|
|
|
|
'year',
|
|
|
|
|
'quarter',
|
|
|
|
|
'type',
|
|
|
|
|
'status',
|
|
|
|
|
'options',
|
|
|
|
|
'created_by',
|
|
|
|
|
'updated_by',
|
|
|
|
|
'deleted_by',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'year' => 'integer',
|
|
|
|
|
'quarter' => 'integer',
|
|
|
|
|
'options' => 'array',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function categories(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(AuditChecklistCategory::class, 'checklist_id')->orderBy('sort_order');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isDraft(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->status === self::STATUS_DRAFT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isCompleted(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->status === self::STATUS_COMPLETED;
|
|
|
|
|
}
|
|
|
|
|
}
|