Files
sam-manage/app/Models/Admin/AdminPmIssue.php
hskwon 432ec2b1c1 feat: [pm] 작업/이슈 긴급(is_urgent) 토글 기능 추가
- Task, Issue 모델에 is_urgent 필드 추가
- TaskService, IssueService에 toggleUrgent() 메서드 추가
- TaskController, IssueController에 toggleUrgent 엔드포인트 추가
- API 라우트에 toggle-urgent 경로 추가
- 프로젝트 상세 페이지 UI 개선:
  - 작업/이슈 행에 긴급 토글 버튼(불꽃 아이콘) 추가
  - 서브 row(아코디언 내 이슈)에도 긴급 토글 추가
  - 서브 row 컬럼을 작업 row와 동일하게 8컬럼으로 정렬
  - 진행중 작업의 이슈 아코디언 자동 열기
  - 이슈 상태 버튼 항상 테두리 표시
2025-11-28 18:08:32 +09:00

183 lines
4.0 KiB
PHP

<?php
namespace App\Models\Admin;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* 프로젝트 관리 - 이슈 모델
*
* @property int $id
* @property int $project_id
* @property int|null $task_id
* @property string $title
* @property string|null $description
* @property string $type
* @property string $status
* @property int|null $created_by
* @property int|null $updated_by
* @property int|null $deleted_by
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon|null $deleted_at
*/
class AdminPmIssue extends Model
{
use SoftDeletes;
protected $table = 'admin_pm_issues';
protected $fillable = [
'project_id',
'task_id',
'title',
'description',
'type',
'status',
'is_urgent',
'created_by',
'updated_by',
'deleted_by',
];
protected $casts = [
'project_id' => 'integer',
'task_id' => 'integer',
'is_urgent' => 'boolean',
'created_by' => 'integer',
'updated_by' => 'integer',
'deleted_by' => 'integer',
];
/**
* 타입 상수
*/
public const TYPE_BUG = 'bug';
public const TYPE_FEATURE = 'feature';
public const TYPE_IMPROVEMENT = 'improvement';
/**
* 상태 상수
*/
public const STATUS_OPEN = 'open';
public const STATUS_IN_PROGRESS = 'in_progress';
public const STATUS_RESOLVED = 'resolved';
public const STATUS_CLOSED = 'closed';
/**
* 타입 목록
*/
public static function getTypes(): array
{
return [
self::TYPE_BUG => '버그',
self::TYPE_FEATURE => '기능',
self::TYPE_IMPROVEMENT => '개선',
];
}
/**
* 상태 목록
*/
public static function getStatuses(): array
{
return [
self::STATUS_OPEN => '대기중',
self::STATUS_IN_PROGRESS => '처리중',
self::STATUS_RESOLVED => '해결됨',
self::STATUS_CLOSED => '종료',
];
}
/**
* 타입별 필터
*/
public function scopeType($query, string $type)
{
return $query->where('type', $type);
}
/**
* 상태별 필터
*/
public function scopeStatus($query, string $status)
{
return $query->where('status', $status);
}
/**
* 열린 이슈 (open, in_progress)
*/
public function scopeOpen($query)
{
return $query->whereIn('status', [self::STATUS_OPEN, self::STATUS_IN_PROGRESS]);
}
/**
* 관계: 프로젝트
*/
public function project(): BelongsTo
{
return $this->belongsTo(AdminPmProject::class, 'project_id');
}
/**
* 관계: 연결된 작업
*/
public function task(): BelongsTo
{
return $this->belongsTo(AdminPmTask::class, 'task_id');
}
/**
* 관계: 생성자
*/
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
/**
* 관계: 수정자
*/
public function updater(): BelongsTo
{
return $this->belongsTo(User::class, 'updated_by');
}
/**
* 타입 아이콘
*/
public function getTypeIconAttribute(): string
{
return match ($this->type) {
self::TYPE_BUG => 'bug',
self::TYPE_FEATURE => 'sparkles',
self::TYPE_IMPROVEMENT => 'arrow-trending-up',
default => 'question-mark-circle',
};
}
/**
* 상태 색상
*/
public function getStatusColorAttribute(): string
{
return match ($this->status) {
self::STATUS_OPEN => 'red',
self::STATUS_IN_PROGRESS => 'yellow',
self::STATUS_RESOLVED => 'green',
self::STATUS_CLOSED => 'gray',
default => 'gray',
};
}
}