Files
muninn/app/Models/Project.php
T
m105andClaude Sonnet 5 a4ff6c0ccb Commit the Projects/Tasks/Ideas/TaskComments feature
This was already implemented, migrated, and running live, but had
never been committed. Bringing it into git: Project/Task/Idea/
TaskComment models, their JSON API (CRUD + status transitions,
task comments, idea<->project linking), Livewire UI pages, and the
nav/route wiring for them. All 42 of its own tests pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-06 20:41:57 +03:00

57 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Project extends Model
{
use HasFactory, SoftDeletes;
public const STATUSES = ['active', 'completed', 'archived', 'on_hold', 'planned'];
protected $fillable = [
'name',
'description',
'status',
'due_at',
];
protected $casts = [
'due_at' => 'datetime',
];
public function tasks(): HasMany
{
return $this->hasMany(Task::class)->orderBy('priority', 'desc')->orderBy('created_at');
}
public function ideas(): HasMany
{
return $this->hasMany(Idea::class)->orderBy('priority', 'desc')->orderBy('created_at', 'desc');
}
public function activeTasks()
{
return $this->tasks()->whereIn('status', ['todo', 'in_progress', 'waiting_review']);
}
public function completedTasks()
{
return $this->tasks()->where('status', 'done');
}
public function scopeActive($query)
{
return $query->where('status', 'active');
}
public function scopeCompleted($query)
{
return $query->where('status', 'completed');
}
}