*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'city' => $this->city, 'state' => $this->state, 'country' => $this->country, 'country_code' => $this->country_code, 'formatted' => $this->formatted(), ]; } /** * Format location as a readable string */ private function formatted(): string { $parts = array_filter([ $this->city, $this->state, $this->country, ]); return implode(', ', $parts); } }