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>
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Ideas;
|
||||
|
||||
use App\Models\Idea;
|
||||
use App\Models\Project;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Layout('components.layouts.app')]
|
||||
class Index extends Component
|
||||
{
|
||||
public bool $showForm = false;
|
||||
|
||||
public ?int $editingId = null;
|
||||
|
||||
public string $title = '';
|
||||
|
||||
public ?string $description = null;
|
||||
|
||||
public string $status = 'new';
|
||||
|
||||
public ?int $projectId = null;
|
||||
|
||||
public int $priority = 0;
|
||||
|
||||
public ?string $category = null;
|
||||
|
||||
public ?string $tags = null;
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public string $statusFilter = '';
|
||||
|
||||
public string $categoryFilter = '';
|
||||
|
||||
public ?int $projectFilter = null;
|
||||
|
||||
public bool $unlinkedFilter = false;
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = Idea::with(['project', 'user']);
|
||||
|
||||
if ($this->search) {
|
||||
$query->search($this->search);
|
||||
}
|
||||
|
||||
if ($this->statusFilter) {
|
||||
$query->where('status', $this->statusFilter);
|
||||
}
|
||||
|
||||
if ($this->categoryFilter) {
|
||||
$query->where('category', $this->categoryFilter);
|
||||
}
|
||||
|
||||
if ($this->projectFilter) {
|
||||
$query->where('project_id', $this->projectFilter);
|
||||
}
|
||||
|
||||
if ($this->unlinkedFilter) {
|
||||
$query->unlinked();
|
||||
}
|
||||
|
||||
$ideas = $query->orderBy('priority', 'desc')->orderBy('created_at', 'desc')->get();
|
||||
|
||||
return view('livewire.ideas.index', [
|
||||
'ideas' => $ideas,
|
||||
'projects' => Project::orderBy('name')->get(),
|
||||
'statuses' => Idea::STATUSES,
|
||||
'categories' => Idea::CATEGORIES,
|
||||
'totalIdeas' => Idea::count(),
|
||||
'newIdeas' => Idea::new()->count(),
|
||||
'consideredIdeas' => Idea::considered()->count(),
|
||||
'plannedIdeas' => Idea::planned()->count(),
|
||||
'implementedIdeas' => Idea::implemented()->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
$this->resetForm();
|
||||
// Pre-select the filtered project if one is selected
|
||||
if ($this->projectFilter) {
|
||||
$this->projectId = $this->projectFilter;
|
||||
}
|
||||
$this->showForm = true;
|
||||
}
|
||||
|
||||
public function edit(int $id): void
|
||||
{
|
||||
$idea = Idea::findOrFail($id);
|
||||
$this->editingId = $idea->id;
|
||||
$this->title = $idea->title;
|
||||
$this->description = $idea->description;
|
||||
$this->status = $idea->status;
|
||||
$this->projectId = $idea->project_id;
|
||||
$this->priority = $idea->priority;
|
||||
$this->category = $idea->category;
|
||||
$this->tags = $idea->tags;
|
||||
$this->showForm = true;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'status' => ['required', 'string', 'in:' . implode(',', Idea::STATUSES)],
|
||||
'projectId' => ['nullable', 'integer', 'exists:projects,id'],
|
||||
'priority' => ['integer', 'min:0', 'max:10'],
|
||||
'category' => ['nullable', 'string', 'in:' . implode(',', Idea::CATEGORIES)],
|
||||
'tags' => ['nullable', 'string', 'max:255'],
|
||||
]);
|
||||
|
||||
Idea::updateOrCreate(['id' => $this->editingId], [
|
||||
'title' => $validated['title'],
|
||||
'description' => $validated['description'],
|
||||
'status' => $validated['status'],
|
||||
'project_id' => $validated['projectId'],
|
||||
'priority' => $validated['priority'],
|
||||
'category' => $validated['category'],
|
||||
'tags' => $validated['tags'],
|
||||
'user_id' => auth()->id(),
|
||||
]);
|
||||
|
||||
$this->resetForm();
|
||||
$this->showForm = false;
|
||||
}
|
||||
|
||||
public function delete(int $id): void
|
||||
{
|
||||
Idea::findOrFail($id)->delete();
|
||||
}
|
||||
|
||||
public function changeStatus(int $id, string $newStatus): void
|
||||
{
|
||||
if (!in_array($newStatus, Idea::STATUSES)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Idea::findOrFail($id)->update(['status' => $newStatus]);
|
||||
}
|
||||
|
||||
public function linkToProject(int $id, int $projectId): void
|
||||
{
|
||||
Idea::findOrFail($id)->update(['project_id' => $projectId]);
|
||||
}
|
||||
|
||||
public function unlinkFromProject(int $id): void
|
||||
{
|
||||
Idea::findOrFail($id)->update(['project_id' => null]);
|
||||
}
|
||||
|
||||
public function clearFilters(): void
|
||||
{
|
||||
$this->search = '';
|
||||
$this->statusFilter = '';
|
||||
$this->categoryFilter = '';
|
||||
$this->projectFilter = null;
|
||||
$this->unlinkedFilter = false;
|
||||
}
|
||||
|
||||
public function resetForm(): void
|
||||
{
|
||||
$this->editingId = null;
|
||||
$this->title = '';
|
||||
$this->description = null;
|
||||
$this->status = 'new';
|
||||
$this->projectId = null;
|
||||
$this->priority = 0;
|
||||
$this->category = null;
|
||||
$this->tags = null;
|
||||
$this->resetValidation();
|
||||
}
|
||||
|
||||
public function getStatusColor(string $status): string
|
||||
{
|
||||
return match ($status) {
|
||||
'new' => 'bg-blue-100 text-blue-800',
|
||||
'considered' => 'bg-yellow-100 text-yellow-800',
|
||||
'planned' => 'bg-purple-100 text-purple-800',
|
||||
'rejected' => 'bg-red-100 text-red-800',
|
||||
'implemented' => 'bg-green-100 text-green-800',
|
||||
default => 'bg-gray-100 text-gray-800',
|
||||
};
|
||||
}
|
||||
|
||||
public function getCategoryColor(string $category): string
|
||||
{
|
||||
return match ($category) {
|
||||
'feature' => 'bg-blue-100 text-blue-800',
|
||||
'improvement' => 'bg-purple-100 text-purple-800',
|
||||
'bugfix' => 'bg-red-100 text-red-800',
|
||||
'research' => 'bg-yellow-100 text-yellow-800',
|
||||
'other' => 'bg-gray-100 text-gray-800',
|
||||
default => 'bg-gray-100 text-gray-800',
|
||||
};
|
||||
}
|
||||
|
||||
public function getPriorityLabel(int $priority): string
|
||||
{
|
||||
if ($priority === 0) return 'None';
|
||||
if ($priority <= 3) return 'Low';
|
||||
if ($priority <= 6) return 'Medium';
|
||||
if ($priority <= 8) return 'High';
|
||||
return 'Critical';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Projects;
|
||||
|
||||
use App\Models\Project;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Layout('components.layouts.app')]
|
||||
class Index extends Component
|
||||
{
|
||||
public bool $showForm = false;
|
||||
|
||||
public ?int $editingId = null;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public ?string $description = null;
|
||||
|
||||
public string $status = 'active';
|
||||
|
||||
public ?string $dueAt = null;
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public string $statusFilter = '';
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = Project::query();
|
||||
|
||||
if ($this->search) {
|
||||
$query->where('name', 'like', '%' . $this->search . '%')
|
||||
->orWhere('description', 'like', '%' . $this->search . '%');
|
||||
}
|
||||
|
||||
if ($this->statusFilter) {
|
||||
$query->where('status', $this->statusFilter);
|
||||
}
|
||||
|
||||
$projects = $query->orderBy('name')->get();
|
||||
|
||||
return view('livewire.projects.index', [
|
||||
'projects' => $projects,
|
||||
'statuses' => Project::STATUSES,
|
||||
'totalProjects' => Project::count(),
|
||||
'activeProjects' => Project::active()->count(),
|
||||
'completedProjects' => Project::completed()->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
$this->resetForm();
|
||||
$this->showForm = true;
|
||||
}
|
||||
|
||||
public function edit(int $id): void
|
||||
{
|
||||
$project = Project::findOrFail($id);
|
||||
$this->editingId = $project->id;
|
||||
$this->name = $project->name;
|
||||
$this->description = $project->description;
|
||||
$this->status = $project->status;
|
||||
$this->dueAt = $project->due_at?->format('Y-m-d\TH:i') ?? '';
|
||||
$this->showForm = true;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'status' => ['required', 'string', 'in:' . implode(',', Project::STATUSES)],
|
||||
'dueAt' => ['nullable', 'date'],
|
||||
]);
|
||||
|
||||
Project::updateOrCreate(['id' => $this->editingId], [
|
||||
'name' => $validated['name'],
|
||||
'description' => $validated['description'],
|
||||
'status' => $validated['status'],
|
||||
'due_at' => $validated['dueAt'] ?: null,
|
||||
]);
|
||||
|
||||
$this->resetForm();
|
||||
$this->showForm = false;
|
||||
}
|
||||
|
||||
public function delete(int $id): void
|
||||
{
|
||||
Project::findOrFail($id)->delete();
|
||||
}
|
||||
|
||||
public function clearFilters(): void
|
||||
{
|
||||
$this->search = '';
|
||||
$this->statusFilter = '';
|
||||
}
|
||||
|
||||
public function resetForm(): void
|
||||
{
|
||||
$this->editingId = null;
|
||||
$this->name = '';
|
||||
$this->description = null;
|
||||
$this->status = 'active';
|
||||
$this->dueAt = null;
|
||||
$this->resetValidation();
|
||||
}
|
||||
|
||||
public function getTasksCount(int $projectId): int
|
||||
{
|
||||
return \App\Models\Task::where('project_id', $projectId)->count();
|
||||
}
|
||||
|
||||
public function getStatusColor(string $status): string
|
||||
{
|
||||
return match ($status) {
|
||||
'active' => 'bg-green-100 text-green-800',
|
||||
'completed' => 'bg-blue-100 text-blue-800',
|
||||
'archived' => 'bg-gray-100 text-gray-800',
|
||||
'on_hold' => 'bg-yellow-100 text-yellow-800',
|
||||
'planned' => 'bg-purple-100 text-purple-800',
|
||||
default => 'bg-gray-100 text-gray-800',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\TaskComments;
|
||||
|
||||
use App\Models\Task;
|
||||
use App\Models\TaskComment;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Layout('components.layouts.app')]
|
||||
class Index extends Component
|
||||
{
|
||||
public ?int $taskId = null;
|
||||
|
||||
public bool $showForm = false;
|
||||
|
||||
public ?int $editingId = null;
|
||||
|
||||
public string $body = '';
|
||||
|
||||
public string $authorType = 'user';
|
||||
|
||||
public string $authorName = '';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
// Get task_id from query parameters
|
||||
if (request()->has('task_id')) {
|
||||
$this->taskId = (int) request('task_id');
|
||||
}
|
||||
|
||||
// Set default author name for user
|
||||
if (auth()->check()) {
|
||||
$this->authorName = auth()->user()->name ?? 'User';
|
||||
} else {
|
||||
$this->authorName = 'User';
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$task = null;
|
||||
$comments = collect();
|
||||
|
||||
if ($this->taskId) {
|
||||
$task = Task::with(['project', 'comments'])->find($this->taskId);
|
||||
$comments = $task ? $task->comments()->orderBy('created_at')->get() : collect();
|
||||
}
|
||||
|
||||
return view('livewire.task-comments.index', [
|
||||
'task' => $task,
|
||||
'comments' => $comments,
|
||||
'authorTypes' => TaskComment::AUTHOR_TYPES,
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
$this->resetForm();
|
||||
$this->showForm = true;
|
||||
}
|
||||
|
||||
public function edit(int $id): void
|
||||
{
|
||||
$comment = TaskComment::findOrFail($id);
|
||||
$this->editingId = $comment->id;
|
||||
$this->body = $comment->body;
|
||||
$this->authorType = $comment->author_type;
|
||||
$this->authorName = $comment->author_name;
|
||||
$this->showForm = true;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
if (!$this->taskId) {
|
||||
$this->addError('taskId', 'Task ID is required');
|
||||
return;
|
||||
}
|
||||
|
||||
$validated = $this->validate([
|
||||
'body' => ['required', 'string'],
|
||||
'authorType' => ['required', 'string', 'in:' . implode(',', TaskComment::AUTHOR_TYPES)],
|
||||
'authorName' => ['required', 'string', 'max:255'],
|
||||
]);
|
||||
|
||||
TaskComment::updateOrCreate(['id' => $this->editingId], [
|
||||
'task_id' => $this->taskId,
|
||||
'body' => $validated['body'],
|
||||
'author_type' => $validated['authorType'],
|
||||
'author_name' => $validated['authorName'],
|
||||
]);
|
||||
|
||||
$this->resetForm();
|
||||
$this->showForm = false;
|
||||
}
|
||||
|
||||
public function delete(int $id): void
|
||||
{
|
||||
TaskComment::findOrFail($id)->delete();
|
||||
}
|
||||
|
||||
public function resetForm(): void
|
||||
{
|
||||
$this->editingId = null;
|
||||
$this->body = '';
|
||||
$this->authorType = 'user';
|
||||
// Keep the author name as it was
|
||||
$this->resetValidation();
|
||||
}
|
||||
|
||||
public function getAuthorColor(string $authorType): string
|
||||
{
|
||||
return match ($authorType) {
|
||||
'ai' => 'bg-purple-100 text-purple-800',
|
||||
'system' => 'bg-gray-100 text-gray-800',
|
||||
'user' => 'bg-blue-100 text-blue-800',
|
||||
default => 'bg-gray-100 text-gray-800',
|
||||
};
|
||||
}
|
||||
|
||||
public function setAuthorAsAI(): void
|
||||
{
|
||||
$this->authorType = 'ai';
|
||||
$this->authorName = 'AI Assistant';
|
||||
}
|
||||
|
||||
public function setAuthorAsUser(): void
|
||||
{
|
||||
$this->authorType = 'user';
|
||||
if (auth()->check()) {
|
||||
$this->authorName = auth()->user()->name ?? 'User';
|
||||
} else {
|
||||
$this->authorName = 'User';
|
||||
}
|
||||
}
|
||||
|
||||
public function setAuthorAsSystem(): void
|
||||
{
|
||||
$this->authorType = 'system';
|
||||
$this->authorName = 'System';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Tasks;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\Task;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Layout('components.layouts.app')]
|
||||
class Index extends Component
|
||||
{
|
||||
public bool $showForm = false;
|
||||
|
||||
public ?int $editingId = null;
|
||||
|
||||
public string $title = '';
|
||||
|
||||
public ?string $description = null;
|
||||
|
||||
public string $status = 'todo';
|
||||
|
||||
public ?int $projectId = null;
|
||||
|
||||
public int $priority = 0;
|
||||
|
||||
public ?string $dueAt = null;
|
||||
|
||||
public ?string $estimatedHours = null;
|
||||
|
||||
public ?string $actualHours = null;
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public string $statusFilter = '';
|
||||
|
||||
public string $priorityFilter = '';
|
||||
|
||||
public ?int $projectFilter = null;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
// If project_id is passed as a query parameter, filter by it
|
||||
if (request()->has('project_id')) {
|
||||
$this->projectFilter = (int) request('project_id');
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = Task::with(['project', 'comments']);
|
||||
|
||||
if ($this->search) {
|
||||
$query->where('title', 'like', '%' . $this->search . '%')
|
||||
->orWhere('description', 'like', '%' . $this->search . '%');
|
||||
}
|
||||
|
||||
if ($this->statusFilter) {
|
||||
$query->where('status', $this->statusFilter);
|
||||
}
|
||||
|
||||
if ($this->priorityFilter) {
|
||||
$query->where('priority', $this->priorityFilter);
|
||||
}
|
||||
|
||||
if ($this->projectFilter) {
|
||||
$query->where('project_id', $this->projectFilter);
|
||||
}
|
||||
|
||||
$tasks = $query->orderBy('priority', 'desc')->orderBy('created_at')->get();
|
||||
|
||||
return view('livewire.tasks.index', [
|
||||
'tasks' => $tasks,
|
||||
'projects' => Project::orderBy('name')->get(),
|
||||
'statuses' => Task::STATUSES,
|
||||
'totalTasks' => Task::count(),
|
||||
'todoTasks' => Task::todo()->count(),
|
||||
'inProgressTasks' => Task::inProgress()->count(),
|
||||
'doneTasks' => Task::done()->count(),
|
||||
'blockedTasks' => Task::blocked()->count(),
|
||||
'waitingReviewTasks' => Task::waitingReview()->count(),
|
||||
'dueSoonTasks' => Task::dueSoon()->count(),
|
||||
'overdueTasks' => Task::overdue()->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
$this->resetForm();
|
||||
// Pre-select the filtered project if one is selected
|
||||
if ($this->projectFilter) {
|
||||
$this->projectId = $this->projectFilter;
|
||||
}
|
||||
$this->showForm = true;
|
||||
}
|
||||
|
||||
public function edit(int $id): void
|
||||
{
|
||||
$task = Task::findOrFail($id);
|
||||
$this->editingId = $task->id;
|
||||
$this->title = $task->title;
|
||||
$this->description = $task->description;
|
||||
$this->status = $task->status;
|
||||
$this->projectId = $task->project_id;
|
||||
$this->priority = $task->priority;
|
||||
$this->dueAt = $task->due_at?->format('Y-m-d\TH:i') ?? '';
|
||||
$this->estimatedHours = $task->estimated_hours;
|
||||
$this->actualHours = $task->actual_hours;
|
||||
$this->showForm = true;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'status' => ['required', 'string', 'in:' . implode(',', Task::STATUSES)],
|
||||
'projectId' => ['nullable', 'integer', 'exists:projects,id'],
|
||||
'priority' => ['integer', 'min:0', 'max:10'],
|
||||
'dueAt' => ['nullable', 'date'],
|
||||
'estimatedHours' => ['nullable', 'numeric', 'min:0'],
|
||||
'actualHours' => ['nullable', 'numeric', 'min:0'],
|
||||
]);
|
||||
|
||||
Task::updateOrCreate(['id' => $this->editingId], [
|
||||
'title' => $validated['title'],
|
||||
'description' => $validated['description'],
|
||||
'status' => $validated['status'],
|
||||
'project_id' => $validated['projectId'],
|
||||
'priority' => $validated['priority'],
|
||||
'due_at' => $validated['dueAt'] ?: null,
|
||||
'estimated_hours' => $validated['estimatedHours'] ?: null,
|
||||
'actual_hours' => $validated['actualHours'] ?: null,
|
||||
]);
|
||||
|
||||
$this->resetForm();
|
||||
$this->showForm = false;
|
||||
}
|
||||
|
||||
public function delete(int $id): void
|
||||
{
|
||||
Task::findOrFail($id)->delete();
|
||||
}
|
||||
|
||||
public function changeStatus(int $id, string $newStatus): void
|
||||
{
|
||||
if (!in_array($newStatus, Task::STATUSES)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$task = Task::findOrFail($id);
|
||||
$task->update(['status' => $newStatus]);
|
||||
|
||||
// Auto-set timestamps based on status
|
||||
if ($newStatus === 'in_progress' && !$task->started_at) {
|
||||
$task->update(['started_at' => now()]);
|
||||
}
|
||||
|
||||
if ($newStatus === 'done' && !$task->completed_at) {
|
||||
$task->update(['completed_at' => now()]);
|
||||
}
|
||||
|
||||
if ($newStatus !== 'in_progress' && $newStatus !== 'done') {
|
||||
$task->update(['started_at' => null, 'completed_at' => null]);
|
||||
}
|
||||
}
|
||||
|
||||
public function clearFilters(): void
|
||||
{
|
||||
$this->search = '';
|
||||
$this->statusFilter = '';
|
||||
$this->priorityFilter = '';
|
||||
$this->projectFilter = null;
|
||||
}
|
||||
|
||||
public function resetForm(): void
|
||||
{
|
||||
$this->editingId = null;
|
||||
$this->title = '';
|
||||
$this->description = null;
|
||||
$this->status = 'todo';
|
||||
$this->projectId = null;
|
||||
$this->priority = 0;
|
||||
$this->dueAt = null;
|
||||
$this->estimatedHours = null;
|
||||
$this->actualHours = null;
|
||||
$this->resetValidation();
|
||||
}
|
||||
|
||||
public function getStatusColor(string $status): string
|
||||
{
|
||||
return match ($status) {
|
||||
'todo' => 'bg-gray-100 text-gray-800',
|
||||
'in_progress' => 'bg-blue-100 text-blue-800',
|
||||
'done' => 'bg-green-100 text-green-800',
|
||||
'blocked' => 'bg-red-100 text-red-800',
|
||||
'waiting_review' => 'bg-yellow-100 text-yellow-800',
|
||||
default => 'bg-gray-100 text-gray-800',
|
||||
};
|
||||
}
|
||||
|
||||
public function getPriorityLabel(int $priority): string
|
||||
{
|
||||
if ($priority === 0) return 'None';
|
||||
if ($priority <= 3) return 'Low';
|
||||
if ($priority <= 6) return 'Medium';
|
||||
if ($priority <= 8) return 'High';
|
||||
return 'Critical';
|
||||
}
|
||||
|
||||
public function getCommentsCount(int $taskId): int
|
||||
{
|
||||
return \App\Models\TaskComment::where('task_id', $taskId)->count();
|
||||
}
|
||||
|
||||
public function startTracking(int $id): void
|
||||
{
|
||||
$task = Task::findOrFail($id);
|
||||
if ($task->status !== 'in_progress') {
|
||||
$task->update(['status' => 'in_progress', 'started_at' => now()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function stopTracking(int $id): void
|
||||
{
|
||||
// This would need more complex time tracking logic
|
||||
// For now, just mark as done
|
||||
$task = Task::findOrFail($id);
|
||||
$task->update(['status' => 'done', 'completed_at' => now()]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user