feat: [roadmap] 중장기 계획 메뉴 및 전용 페이지 개발
- 모델: AdminRoadmapPlan, AdminRoadmapMilestone - 서비스: RoadmapPlanService, RoadmapMilestoneService - FormRequest: Store/Update Plan/Milestone 4개 - 컨트롤러: Blade(RoadmapController), API(Plan/Milestone) 3개 - 라우트: web.php, api.php에 roadmap 라우트 추가 - Blade 뷰: 대시보드, 목록, 생성, 수정, 상세, 파셜 테이블 6개 - HTMX 기반 필터링/페이지네이션, 마일스톤 인라인 추가/토글
This commit is contained in:
102
app/Models/Admin/AdminRoadmapMilestone.php
Normal file
102
app/Models/Admin/AdminRoadmapMilestone.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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;
|
||||
|
||||
class AdminRoadmapMilestone extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'admin_roadmap_milestones';
|
||||
|
||||
protected $fillable = [
|
||||
'plan_id',
|
||||
'title',
|
||||
'description',
|
||||
'status',
|
||||
'due_date',
|
||||
'completed_at',
|
||||
'assignee_id',
|
||||
'sort_order',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'plan_id' => 'integer',
|
||||
'due_date' => 'date',
|
||||
'completed_at' => 'datetime',
|
||||
'assignee_id' => 'integer',
|
||||
'sort_order' => 'integer',
|
||||
'created_by' => 'integer',
|
||||
'updated_by' => 'integer',
|
||||
'deleted_by' => 'integer',
|
||||
];
|
||||
|
||||
public const STATUS_PENDING = 'pending';
|
||||
|
||||
public const STATUS_COMPLETED = 'completed';
|
||||
|
||||
public static function getStatuses(): array
|
||||
{
|
||||
return [
|
||||
self::STATUS_PENDING => '진행중',
|
||||
self::STATUS_COMPLETED => '완료',
|
||||
];
|
||||
}
|
||||
|
||||
public function plan(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AdminRoadmapPlan::class, 'plan_id');
|
||||
}
|
||||
|
||||
public function assignee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assignee_id');
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function getStatusLabelAttribute(): string
|
||||
{
|
||||
return self::getStatuses()[$this->status] ?? $this->status;
|
||||
}
|
||||
|
||||
public function getIsCompletedAttribute(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_COMPLETED;
|
||||
}
|
||||
|
||||
public function getDdayAttribute(): ?int
|
||||
{
|
||||
if (! $this->due_date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return now()->startOfDay()->diffInDays($this->due_date, false);
|
||||
}
|
||||
|
||||
public function getDueStatusAttribute(): ?string
|
||||
{
|
||||
if (! $this->due_date || $this->status === self::STATUS_COMPLETED) {
|
||||
return null;
|
||||
}
|
||||
$dday = $this->dday;
|
||||
if ($dday < 0) {
|
||||
return 'overdue';
|
||||
}
|
||||
if ($dday <= 7) {
|
||||
return 'due_soon';
|
||||
}
|
||||
|
||||
return 'normal';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user