AdminPmIssue 모델에 마감일 관련 스코프/속성 추가
- scopeOverdue: 마감일 지난 미해결 이슈 필터 - scopeDueSoon: 마감일 임박 이슈 필터 (N일 이내) - scopeNeedsAttention: 주의 필요 이슈 통합 스코프 - getDdayAttribute: D-day 계산 접근자 - getDueStatusAttribute: 마감 상태 접근자 (overdue/due_soon/normal)
This commit is contained in:
@@ -136,6 +136,74 @@ public function scopeOpen($query)
|
||||
return $query->whereIn('status', [self::STATUS_OPEN, self::STATUS_IN_PROGRESS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 마감일 지난 이슈 (미해결)
|
||||
*/
|
||||
public function scopeOverdue($query)
|
||||
{
|
||||
return $query->whereNotNull('due_date')
|
||||
->where('due_date', '<', now()->startOfDay())
|
||||
->whereIn('status', [self::STATUS_OPEN, self::STATUS_IN_PROGRESS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 마감일 임박 (N일 이내, 미해결)
|
||||
*/
|
||||
public function scopeDueSoon($query, int $days = 3)
|
||||
{
|
||||
return $query->whereNotNull('due_date')
|
||||
->whereBetween('due_date', [now()->startOfDay(), now()->addDays($days)->endOfDay()])
|
||||
->whereIn('status', [self::STATUS_OPEN, self::STATUS_IN_PROGRESS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 주의 필요 이슈 (마감 초과 + 마감 임박 + 긴급)
|
||||
*/
|
||||
public function scopeNeedsAttention($query)
|
||||
{
|
||||
return $query->whereIn('status', [self::STATUS_OPEN, self::STATUS_IN_PROGRESS])
|
||||
->where(function ($q) {
|
||||
$q->where('is_urgent', true)
|
||||
->orWhere(function ($q2) {
|
||||
$q2->whereNotNull('due_date')
|
||||
->where('due_date', '<=', now()->addDays(3)->endOfDay());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* D-day 계산
|
||||
*/
|
||||
public function getDdayAttribute(): ?int
|
||||
{
|
||||
if (! $this->due_date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return now()->startOfDay()->diffInDays($this->due_date, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 마감 상태 (overdue, due_soon, normal, null)
|
||||
*/
|
||||
public function getDueStatusAttribute(): ?string
|
||||
{
|
||||
if (! $this->due_date || in_array($this->status, [self::STATUS_RESOLVED, self::STATUS_CLOSED])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dday = $this->dday;
|
||||
|
||||
if ($dday < 0) {
|
||||
return 'overdue';
|
||||
}
|
||||
if ($dday <= 3) {
|
||||
return 'due_soon';
|
||||
}
|
||||
|
||||
return 'normal';
|
||||
}
|
||||
|
||||
/**
|
||||
* 관계: 프로젝트
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user