'datetime', 'started_at' => 'datetime', 'completed_at' => 'datetime', ]; public function project(): BelongsTo { return $this->belongsTo(Project::class); } public function comments(): HasMany { return $this->hasMany(TaskComment::class)->orderBy('created_at'); } public function scopeByStatus($query, string $status) { return $query->where('status', $status); } public function scopeTodo($query) { return $query->where('status', 'todo'); } public function scopeInProgress($query) { return $query->where('status', 'in_progress'); } public function scopeDone($query) { return $query->where('status', 'done'); } public function scopeBlocked($query) { return $query->where('status', 'blocked'); } public function scopeWaitingReview($query) { return $query->where('status', 'waiting_review'); } public function scopeDueSoon($query, int $days = 3) { return $query->where('due_at', '>=', now()) ->where('due_at', '<=', now()->addDays($days)) ->where('status', '!=', 'done'); } public function scopeOverdue($query) { return $query->where('due_at', '<', now()) ->where('status', '!=', 'done'); } }