- 마이그레이션: 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>
58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Qualitys;
|
|
|
|
use App\Models\Traits\Auditable;
|
|
use App\Models\Traits\BelongsToTenant;
|
|
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;
|
|
}
|
|
}
|