*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'title' => $this->title, 'asset_id' => $this->asset_id, 'parent_id' => $this->parent_id, 'requirement_total' => $this->requirements()->count(), 'project_total' => $this->projects()->count(), 'begin' => $this->begin, 'end' => $this->end, 'description' => $this->description, 'children' => $this->parent_id == 0 ? PlanResource::collection($this->children) : [], ]; } }