lundi 30 octobre 2017

Laravel 5 get attribute from collection

I have a $location collection that looks like this:

Collection {#225 ▼
  #items: array:5 [▼
    0 => GoogleAddress {#336 ▼
      -id: "ChIJjWwHAP72w0cR44_HJ-bRcJE"
      -locationType: "ROOFTOP"
      -resultType: array:1 [▶]
      -formattedAddress: ""
      -streetAddress: null
      -intersection: null
      -political: ""
      -colloquialArea: null
      -ward: null
      -neighborhood: null
      -premise: null
      -subpremise: null
      -naturalFeature: null
      -airport: null
      -park: null
      -pointOfInterest: null
      -establishment: null
      -subLocalityLevels: AdminLevelCollection {#339 ▶}
      -coordinates: Coordinates {#331 ▶}
      -bounds: Bounds {#332 ▶}
      -streetNumber: "21"
      -streetName: ""
      -subLocality: null
      -locality: ""
      -postalCode: ""
      -adminLevels: AdminLevelCollection {#337 ▶}
      -country: Country {#335 ▶}
      -timezone: null
      -providedBy: "google_maps"
    }
    1 => GoogleAddress {#344 ▶}
    2 => GoogleAddress {#352 ▶}
    3 => GoogleAddress {#360 ▶}
    4 => GoogleAddress {#368 ▶}
  ]
}

So I am trying to get the formattedAddress like this:

$location[0]->formattedAddress

But I get the following error:

Cannot access private property Geocoder\Provider\GoogleMaps\Model\GoogleAddress::$formattedAddress

Anyone can help me out here?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2z3aDeM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire