$this->id, 'title' => $this->title, 'description' => $this->description, 'phase' => $this->phase, 'order' => $this->order, 'priority' => $this->priority, 'origin' => $this->origin, 'scope' => $this->scope, 'sector' => $this->sector, 'due_date' => $this->due_date?->format('Y-m-d'), 'responsible_user_id' => $this->responsible_user_id, 'created_by_user_id' => $this->created_by_user_id, 'unit_id' => $this->unit_id, 'target_unit_id' => $this->target_unit_id, // Resolved names for the UI 'created_by_user_name' => $this->whenLoaded('createdByUser', fn() => $this->createdByUser?->name), 'responsible_user_name'=> $this->whenLoaded('responsibleUser', fn() => $this->responsibleUser?->name), 'applicant_unit_name' => $this->whenLoaded('applicantUnit', fn() => $this->applicantUnit?->fantasy_name), 'target_unit_name' => $this->whenLoaded('targetUnit', fn() => $this->targetUnit?->fantasy_name), 'replies_count' => $this->whenCounted('replies'), 'created_at' => $this->created_at?->format('d/m/Y H:i'), 'updated_at' => $this->updated_at?->format('d/m/Y H:i'), ]; } /** * @param \Illuminate\Database\Eloquent\Collection $resource * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public static function collection($resource): AnonymousResourceCollection { return parent::collection($resource); } }