주요 기능:
- 일일 로그 CRUD (생성, 조회, 수정, 삭제, 복원, 영구삭제)
- 로그 항목(Entry) 관리 (추가, 상태변경, 삭제, 순서변경)
- 주간 타임라인 (최근 7일 진행률 표시)
- 테이블 리스트 아코디언 상세보기
- 담당자 자동완성 (일반 사용자는 슈퍼관리자 목록 제외)
- HTMX 기반 동적 테이블 로딩 및 필터링
- Soft Delete 지원
파일 추가:
- Models: AdminPmDailyLog, AdminPmDailyLogEntry
- Controllers: DailyLogController (Web, API)
- Service: DailyLogService
- Requests: StoreDailyLogRequest, UpdateDailyLogRequest
- Views: index, show, table partial, modal-form partial
라우트 추가:
- Web: /daily-logs, /daily-logs/today, /daily-logs/{id}
- API: /api/admin/daily-logs/* (CRUD + 항목관리)
147 lines
3.4 KiB
PHP
147 lines
3.4 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\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* 프로젝트 관리 - 일일 로그 모델
|
|
*
|
|
* @property int $id
|
|
* @property int $tenant_id
|
|
* @property int|null $project_id
|
|
* @property \Carbon\Carbon $log_date
|
|
* @property string|null $summary
|
|
* @property int $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 AdminPmDailyLog extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'admin_pm_daily_logs';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'project_id',
|
|
'log_date',
|
|
'summary',
|
|
'created_by',
|
|
'updated_by',
|
|
'deleted_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'log_date' => 'date',
|
|
'tenant_id' => 'integer',
|
|
'project_id' => 'integer',
|
|
'created_by' => 'integer',
|
|
'updated_by' => 'integer',
|
|
'deleted_by' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 관계: 프로젝트
|
|
*/
|
|
public function project(): BelongsTo
|
|
{
|
|
return $this->belongsTo(AdminPmProject::class, 'project_id');
|
|
}
|
|
|
|
/**
|
|
* 관계: 항목들
|
|
*/
|
|
public function entries(): HasMany
|
|
{
|
|
return $this->hasMany(AdminPmDailyLogEntry::class, 'daily_log_id')->orderBy('sort_order');
|
|
}
|
|
|
|
/**
|
|
* 관계: 생성자
|
|
*/
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
/**
|
|
* 관계: 수정자
|
|
*/
|
|
public function updater(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'updated_by');
|
|
}
|
|
|
|
/**
|
|
* 스코프: 테넌트 필터
|
|
*/
|
|
public function scopeTenant($query, int $tenantId)
|
|
{
|
|
return $query->where('tenant_id', $tenantId);
|
|
}
|
|
|
|
/**
|
|
* 스코프: 날짜 범위 필터
|
|
*/
|
|
public function scopeDateRange($query, ?string $startDate, ?string $endDate)
|
|
{
|
|
if ($startDate) {
|
|
$query->where('log_date', '>=', $startDate);
|
|
}
|
|
if ($endDate) {
|
|
$query->where('log_date', '<=', $endDate);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
/**
|
|
* 스코프: 프로젝트 필터
|
|
*/
|
|
public function scopeProject($query, ?int $projectId)
|
|
{
|
|
if ($projectId) {
|
|
return $query->where('project_id', $projectId);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
/**
|
|
* 항목 통계
|
|
*/
|
|
public function getEntryStatsAttribute(): array
|
|
{
|
|
return [
|
|
'total' => $this->entries()->count(),
|
|
'todo' => $this->entries()->where('status', AdminPmDailyLogEntry::STATUS_TODO)->count(),
|
|
'in_progress' => $this->entries()->where('status', AdminPmDailyLogEntry::STATUS_IN_PROGRESS)->count(),
|
|
'done' => $this->entries()->where('status', AdminPmDailyLogEntry::STATUS_DONE)->count(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 프로젝트명 (없으면 '전체')
|
|
*/
|
|
public function getProjectNameAttribute(): string
|
|
{
|
|
return $this->project?->name ?? '전체';
|
|
}
|
|
|
|
/**
|
|
* 포맷된 날짜
|
|
*/
|
|
public function getFormattedDateAttribute(): string
|
|
{
|
|
return $this->log_date->format('Y-m-d (D)');
|
|
}
|
|
}
|