- 품질관리서(quality_documents) CRUD API 14개 엔드포인트 - 실적신고(performance_reports) 관리 API 6개 엔드포인트 - DB 마이그레이션 4개 테이블 (quality_documents, quality_document_orders, quality_document_locations, performance_reports) - 모델 4개 + 서비스 2개 + 컨트롤러 2개 + FormRequest 4개 - stats() ambiguous column 버그 수정 (JOIN 시 테이블 접두사 추가) - missing() status_code 컬럼명/값 수정 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
77 lines
1.6 KiB
PHP
77 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Qualitys;
|
|
|
|
use App\Models\Members\User;
|
|
use App\Traits\Auditable;
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class PerformanceReport extends Model
|
|
{
|
|
use Auditable, BelongsToTenant, SoftDeletes;
|
|
|
|
protected $table = 'performance_reports';
|
|
|
|
const STATUS_UNCONFIRMED = 'unconfirmed';
|
|
|
|
const STATUS_CONFIRMED = 'confirmed';
|
|
|
|
const STATUS_REPORTED = 'reported';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'quality_document_id',
|
|
'year',
|
|
'quarter',
|
|
'confirmation_status',
|
|
'confirmed_date',
|
|
'confirmed_by',
|
|
'memo',
|
|
'created_by',
|
|
'updated_by',
|
|
'deleted_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'confirmed_date' => 'date',
|
|
'year' => 'integer',
|
|
'quarter' => 'integer',
|
|
];
|
|
|
|
// ===== Relationships =====
|
|
|
|
public function qualityDocument()
|
|
{
|
|
return $this->belongsTo(QualityDocument::class);
|
|
}
|
|
|
|
public function confirmer()
|
|
{
|
|
return $this->belongsTo(User::class, 'confirmed_by');
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
// ===== Status Helpers =====
|
|
|
|
public function isUnconfirmed(): bool
|
|
{
|
|
return $this->confirmation_status === self::STATUS_UNCONFIRMED;
|
|
}
|
|
|
|
public function isConfirmed(): bool
|
|
{
|
|
return $this->confirmation_status === self::STATUS_CONFIRMED;
|
|
}
|
|
|
|
public function isReported(): bool
|
|
{
|
|
return $this->confirmation_status === self::STATUS_REPORTED;
|
|
}
|
|
}
|