feat: [pm] 프로젝트 진행 관리 시스템 구현
- Models: AdminPmProject, AdminPmTask, AdminPmIssue - Services: ProjectService, TaskService, IssueService, ImportService - API Controllers: ProjectController, TaskController, IssueController, ImportController - FormRequests: Store/Update/BulkAction 요청 검증 - Views: 대시보드, 프로젝트 CRUD, JSON Import 화면 - Routes: API 42개 + Web 6개 엔드포인트 주요 기능: - 프로젝트/작업/이슈 계층 구조 관리 - 상태 변경, 우선순위, 마감일 추적 - 작업 순서 드래그앤드롭 (reorder API) - JSON Import로 일괄 등록 - Soft Delete 및 복원
This commit is contained in:
154
app/Models/Admin/AdminPmProject.php
Normal file
154
app/Models/Admin/AdminPmProject.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Admin;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* 프로젝트 관리 - 프로젝트 모델
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string|null $description
|
||||
* @property string $status
|
||||
* @property \Carbon\Carbon|null $start_date
|
||||
* @property \Carbon\Carbon|null $end_date
|
||||
* @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 AdminPmProject extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'admin_pm_projects';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'status',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'created_by' => 'integer',
|
||||
'updated_by' => 'integer',
|
||||
'deleted_by' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 상태 상수
|
||||
*/
|
||||
public const STATUS_ACTIVE = 'active';
|
||||
|
||||
public const STATUS_COMPLETED = 'completed';
|
||||
|
||||
public const STATUS_ON_HOLD = 'on_hold';
|
||||
|
||||
/**
|
||||
* 상태 목록
|
||||
*/
|
||||
public static function getStatuses(): array
|
||||
{
|
||||
return [
|
||||
self::STATUS_ACTIVE => '진행중',
|
||||
self::STATUS_COMPLETED => '완료',
|
||||
self::STATUS_ON_HOLD => '보류',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 활성 프로젝트만 조회
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_ACTIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관계: 작업 목록
|
||||
*/
|
||||
public function tasks(): HasMany
|
||||
{
|
||||
return $this->hasMany(AdminPmTask::class, 'project_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 관계: 이슈 목록
|
||||
*/
|
||||
public function issues(): HasMany
|
||||
{
|
||||
return $this->hasMany(AdminPmIssue::class, 'project_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 getProgressAttribute(): float
|
||||
{
|
||||
$total = $this->tasks()->count();
|
||||
if ($total === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$done = $this->tasks()->where('status', AdminPmTask::STATUS_DONE)->count();
|
||||
|
||||
return round(($done / $total) * 100, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 작업 통계
|
||||
*/
|
||||
public function getTaskStatsAttribute(): array
|
||||
{
|
||||
return [
|
||||
'total' => $this->tasks()->count(),
|
||||
'todo' => $this->tasks()->where('status', AdminPmTask::STATUS_TODO)->count(),
|
||||
'in_progress' => $this->tasks()->where('status', AdminPmTask::STATUS_IN_PROGRESS)->count(),
|
||||
'done' => $this->tasks()->where('status', AdminPmTask::STATUS_DONE)->count(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 이슈 통계
|
||||
*/
|
||||
public function getIssueStatsAttribute(): array
|
||||
{
|
||||
return [
|
||||
'total' => $this->issues()->count(),
|
||||
'open' => $this->issues()->where('status', AdminPmIssue::STATUS_OPEN)->count(),
|
||||
'in_progress' => $this->issues()->where('status', AdminPmIssue::STATUS_IN_PROGRESS)->count(),
|
||||
'resolved' => $this->issues()->where('status', AdminPmIssue::STATUS_RESOLVED)->count(),
|
||||
'closed' => $this->issues()->where('status', AdminPmIssue::STATUS_CLOSED)->count(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user