*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'name' => $this->name, 'description' => $this->description ?? null, 'clients_count' => $this->whenCounted('clients'), 'client_ids' => $this->whenLoaded('clients', fn () => $this->clients->pluck('id')->values()), 'clients' => ClientResource::collection($this->whenLoaded('clients')), 'created_at' => $this->created_at?->format('Y-m-d H:i:s'), 'updated_at' => $this->updated_at?->format('Y-m-d H:i:s'), ]; } }