*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'name' => $this->name, 'external_id' => $this->external_id, 'protocol' => $this->protocol, 'status' => $this->live_status ?? $this->status, // Nested resources are resolved (not returned as bare Resource // instances) — a Resource embedded as a value gets wrapped in its // own `data` key when the parent response goes through Laravel's // Responsable pipeline (Inertia props, ->response() in the API), // which would double up with the outer collection's own wrapping. 'zone' => $this->whenLoaded('zone', fn ($zone) => (new ZoneResource($zone))->resolve()), 'device_type' => $this->whenLoaded('deviceType', fn ($type) => (new DeviceTypeResource($type))->resolve()), 'created_at' => $this->created_at, ]; } }