'integer', 'assignee_id' => 'integer', 'sort_order' => 'integer', ]; /** * 담당자 유형 상수 */ public const TYPE_TEAM = 'team'; public const TYPE_USER = 'user'; /** * 상태 상수 */ public const STATUS_TODO = 'todo'; public const STATUS_IN_PROGRESS = 'in_progress'; public const STATUS_DONE = 'done'; /** * 담당자 유형 목록 */ public static function getAssigneeTypes(): array { return [ self::TYPE_TEAM => '팀', self::TYPE_USER => '개인', ]; } /** * 상태 목록 */ public static function getStatuses(): array { return [ self::STATUS_TODO => '예정', self::STATUS_IN_PROGRESS => '진행중', self::STATUS_DONE => '완료', ]; } /** * 관계: 일일 로그 */ public function dailyLog(): BelongsTo { return $this->belongsTo(AdminPmDailyLog::class, 'daily_log_id'); } /** * 관계: 사용자 담당자 (assignee_type이 user인 경우) */ public function assigneeUser(): BelongsTo { return $this->belongsTo(User::class, 'assignee_id'); } /** * 스코프: 상태별 필터 */ public function scopeStatus($query, string $status) { return $query->where('status', $status); } /** * 스코프: 담당자 유형별 필터 */ public function scopeAssigneeType($query, string $type) { return $query->where('assignee_type', $type); } /** * 상태 라벨 (한글) */ public function getStatusLabelAttribute(): string { return self::getStatuses()[$this->status] ?? $this->status; } /** * 담당자 유형 라벨 (한글) */ public function getAssigneeTypeLabelAttribute(): string { return self::getAssigneeTypes()[$this->assignee_type] ?? $this->assignee_type; } /** * 상태별 색상 클래스 */ public function getStatusColorAttribute(): string { return match ($this->status) { self::STATUS_TODO => 'bg-gray-100 text-gray-800', self::STATUS_IN_PROGRESS => 'bg-yellow-100 text-yellow-800', self::STATUS_DONE => 'bg-green-100 text-green-800', default => 'bg-gray-100 text-gray-800', }; } /** * 담당자 유형별 색상 클래스 */ public function getAssigneeTypeColorAttribute(): string { return match ($this->assignee_type) { self::TYPE_TEAM => 'bg-purple-100 text-purple-800', self::TYPE_USER => 'bg-blue-100 text-blue-800', default => 'bg-gray-100 text-gray-800', }; } }