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>
36 lines
1.4 KiB
PHP
36 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class TaskResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'title' => $this->title,
|
|
'description' => $this->description,
|
|
'status' => $this->status,
|
|
'priority' => $this->priority,
|
|
'due_at' => $this->due_at?->toIso8601String(),
|
|
'started_at' => $this->started_at?->toIso8601String(),
|
|
'completed_at' => $this->completed_at?->toIso8601String(),
|
|
'estimated_hours' => $this->estimated_hours,
|
|
'actual_hours' => $this->actual_hours,
|
|
'project_id' => $this->project_id,
|
|
'comment_count' => $this->whenLoaded('comments', fn () => $this->comments->count()),
|
|
'project' => $this->whenLoaded('project', fn () => [
|
|
'id' => $this->project->id,
|
|
'name' => $this->project->name,
|
|
]),
|
|
'comments' => $this->whenLoaded('comments', fn () => TaskCommentResource::collection($this->comments)),
|
|
'created_at' => $this->created_at->toIso8601String(),
|
|
'updated_at' => $this->updated_at->toIso8601String(),
|
|
'deleted_at' => $this->deleted_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|