php-agentic/Models/Task.php

68 lines
1.3 KiB
PHP
Raw Normal View History

2026-01-27 00:28:29 +00:00
<?php
declare(strict_types=1);
namespace Core\Mod\Agentic\Models;
2026-01-27 00:28:29 +00:00
use Illuminate\Database\Eloquent\Model;
use Core\Mod\Tenant\Concerns\BelongsToWorkspace;
class Task extends Model
{
use BelongsToWorkspace;
protected $fillable = [
'workspace_id',
'title',
'description',
'status',
'priority',
'category',
'file_ref',
'line_ref',
];
protected $casts = [
'line_ref' => 'integer',
];
public function scopePending($query)
{
return $query->where('status', 'pending');
}
public function scopeInProgress($query)
{
return $query->where('status', 'in_progress');
}
public function scopeDone($query)
{
return $query->where('status', 'done');
}
public function scopeActive($query)
{
return $query->whereIn('status', ['pending', 'in_progress']);
}
public function getStatusBadgeAttribute(): string
{
return match ($this->status) {
'done' => '✓',
'in_progress' => '→',
default => '○',
};
}
public function getPriorityBadgeAttribute(): string
{
return match ($this->priority) {
'urgent' => '🔴',
'high' => '🟠',
'low' => '🔵',
default => '',
};
}
}