'boolean', 'done_at' => 'datetime', 'snooze_until' => 'datetime', 'deadline' => 'datetime', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function project(): BelongsTo { return $this->belongsTo(Project::class); } public function tags(): BelongsToMany { return $this->belongsToMany(Tag::class); } /** Tareas activas (no hechas y no snoozed) */ public function scopeActive(Builder $q): Builder { return $q->where('done', false) ->where(function ($q2) { $q2->whereNull('snooze_until') ->orWhere('snooze_until', '<=', now()); }); } public function scopeForUser(Builder $q, int $userId): Builder { return $q->where('user_id', $userId); } public function getNextDueInAttribute(): int { if (! $this->deadline) return 0; if ($this->deadline->isPast()) return 0; return max(0, now()->diffInSeconds($this->deadline, false)); } }