*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'title' => $this->title, 'description' => $this->description, 'priority' => $this->priority, 'due_date' => $this->due_date?->toISOString(), 'is_completed' => $this->is_completed, 'collection_id' => $this->collection_id, 'assigned_events_count' => $this->assignedEvents()->count(), // TaskCollectionResource wird später implementiert // 'collection' => $this->whenLoaded('taskCollection', function () { // return new TaskCollectionResource($this->taskCollection); // }), 'assigned_events' => $this->whenLoaded('assignedEvents', function () { return EventResource::collection($this->assignedEvents); }), // UserResource wird später implementiert // 'assigned_to' => $this->whenLoaded('assignedTo', function () { // return new UserResource($this->assignedTo); // }), 'created_at' => $this->created_at->toISOString(), 'updated_at' => $this->updated_at->toISOString(), ]; } }