I am working with Laravel 8.0 with the Quickbooks API, When I run a quickbooks query to get all the customers, I get back a response that looks like this.
Array
(
[0] => QuickBooksOnline\API\Data\IPPCustomer Object
(
[Taxable] => true
[BillAddr] => QuickBooksOnline\API\Data\IPPPhysicalAddress Object
(
[Id] => 2
[Line1] => 4581 Finch St.
[Line2] =>
[Line3] =>
[Line4] =>
[Line5] =>
[City] => Bayshore
[Country] =>
[CountryCode] =>
[County] =>
[CountrySubDivisionCode] => CA
[PostalCode] => 94326
[PostalCodeSuffix] =>
[Lat] => INVALID
[Long] => INVALID
[Tag] =>
[Note] =>
)
[ShipAddr] => QuickBooksOnline\API\Data\IPPPhysicalAddress Object
(
[Id] => 2
[Line1] => 4581 Finch St.
[Line2] =>
[Line3] =>
[Line4] =>
[Line5] =>
[City] => Bayshore
[Country] =>
[CountryCode] =>
[County] =>
[CountrySubDivisionCode] => CA
[PostalCode] => 94326
[PostalCodeSuffix] =>
[Lat] => INVALID
[Long] => INVALID
[Tag] =>
[Note] =>
)
[OtherAddr] =>
[ContactName] =>
[AltContactName] =>
[Notes] =>
[Job] => false
[BillWithParent] => false
[RootCustomerRef] =>
[ParentRef] =>
[Level] =>
[CustomerTypeRef] =>
[SalesTermRef] =>
[SalesRepRef] =>
[TaxGroupCodeRef] =>
[TaxRateRef] =>
[PaymentMethodRef] =>
[CCDetail] =>
[PriceLevelRef] =>
[Balance] => 239.00
[OpenBalanceDate] =>
[BalanceWithJobs] => 239.00
[CreditLimit] =>
[AcctNum] =>
[CurrencyRef] => USD
[OverDueBalance] =>
[TotalRevenue] =>
[TotalExpense] =>
[PreferredDeliveryMethod] => Print
[ResaleNum] =>
[JobInfo] =>
[TDSEnabled] =>
[CustomerEx] =>
[SecondaryTaxIdentifier] =>
[ARAccountRef] =>
[PrimaryTaxIdentifier] =>
[TaxExemptionReasonId] =>
[IsProject] => false
[BusinessNumber] =>
[GSTIN] =>
[GSTRegistrationType] =>
[IsCISContractor] =>
[ClientCompanyId] =>
[ClientEntityId] => 0
[IntuitId] =>
[Organization] =>
[Title] =>
[GivenName] => Amy
[MiddleName] =>
[FamilyName] => Lauterbach
[Suffix] =>
[FullyQualifiedName] => Amy's Bird Sanctuary
[CompanyName] => Amy's Bird Sanctuary
[DisplayName] => Amy's Bird Sanctuary
[PrintOnCheckName] => Amy's Bird Sanctuary
[UserId] =>
[Active] => true
[V4IDPseudonym] => 002098e9355296552b4ab8a26366974b39e91e
[PrimaryPhone] => QuickBooksOnline\API\Data\IPPTelephoneNumber Object
(
[Id] =>
[DeviceType] =>
[CountryCode] =>
[AreaCode] =>
[ExchangeCode] =>
[Extension] =>
[FreeFormNumber] => (650) 555-3311
[Default] =>
[Tag] =>
)
[AlternatePhone] =>
[Mobile] =>
[Fax] =>
[PrimaryEmailAddr] => QuickBooksOnline\API\Data\IPPEmailAddress Object
(
[Id] =>
[Address] => [email protected]
[Default] =>
[Tag] =>
)
[WebAddr] =>
[OtherContactInfo] =>
[DefaultTaxCodeRef] =>
[Id] => 1
[SyncToken] => 0
[MetaData] => QuickBooksOnline\API\Data\IPPModificationMetaData Object
(
[CreatedByRef] =>
[CreateTime] => 2020-12-31T16:48:43-08:00
[LastModifiedByRef] =>
[LastUpdatedTime] => 2021-01-07T13:39:32-08:00
[LastChangedInQB] =>
[Synchronized] =>
)
[CustomField] =>
[AttachableRef] =>
[domain] =>
[status] =>
[sparse] =>
)
I pass off that data to the view, and then inside my blade template I foreach the customers like so.
@foreach($customers as $customer)
<h1>{{ $customer->GivenName.' '.$customer->FamilyName }}</h1>
@endforeach
My issue is when I to access the BillAddr inside of my foreach. {{$customer->BillAddr->Line1 }}
@foreach($customers as $customer)
<h1>{{ $customer->GivenName.' '.$customer->FamilyName }}</h1>
<h2>address: {{$customer->BillAddr->Line1 }}<h2>
@endforeach
no matter what I can't seem to access the data, I've tried to access it using different ways, such as.
- {{$customer->BillAddr->Line1 }}
- {{$customer->['BillAddr']['Line1'] }}
- {{$customer['BillAddr']['Line1'] }}
etc..
I'm getting the error
errorException Trying to get property 'Line1' of non-object
If I try to access the property like this
$customer->BillAddr['Line1']
Then I also get an error, but its a different error.
Cannot use object of type QuickBooksOnline\API\Data\IPPPhysicalAddress as array
array_chunk()usage necessary for your particular project? - summea$customervariable might not be getting set with a customer object. Thenon-objectpart of your error message might help support that thought. Would it be possible to show part of your related controller code that relates to this view? In cases like this, it might be helpful to temporarily add aprint_r($customers);type of line in your code to check and see if that variable has any data or if it is empty. - summea