{#5729 +"CustomerRef": {#5728 +"value": "70" +"name": "Customer Name" } +"DepositToAccountRef": {#5727 +"value": "135" } +"TotalAmt": 133.0 +"UnappliedAmt": 0 +"ProcessPayment": false +"domain": "QBO" +"sparse": false +"Id": "208" +"SyncToken": "0" +"MetaData": {#5726 +"CreateTime": "2023-05-12T22:19:55-07:00" +"LastUpdatedTime": "2023-05-12T22:19:55-07:00" } +"TxnDate": "2023-05-13" +"CurrencyRef": {#5725 +"value": "AUD" +"name": "Australian Dollar" } +"Line": array:2 [ 0 => {#5724 +"Amount": 1.0 +"LinkedTxn": array:1 [ 0 => {#5723 +"TxnId": "202" +"TxnType": "Invoice" } ] +"LineEx": {#5722 +"any": array:3 [ 0 => {#5721 +"name": "{http://schema.intuit.com/finance/v3}NameValue" +"declaredType": "com.intuit.schema.finance.v3.NameValue" +"scope": "javax.xml.bind.JAXBElement$GlobalScope" +"value": {#5720 +"Name": "txnId" +"Value": "202" } +"nil": false +"globalScope": true +"typeSubstituted": false } 1 => {#5719 +"name": "{http://schema.intuit.com/finance/v3}NameValue" +"declaredType": "com.intuit.schema.finance.v3.NameValue" +"scope": "javax.xml.bind.JAXBElement$GlobalScope" +"value": {#5718 +"Name": "txnOpenBalance" +"Value": "132.00" } +"nil": false +"globalScope": true +"typeSubstituted": false } 2 => {#5717 +"name": "{http://schema.intuit.com/finance/v3}NameValue" +"declaredType": "com.intuit.schema.finance.v3.NameValue" +"scope": "javax.xml.bind.JAXBElement$GlobalScope" +"value": {#5716 +"Name": "txnReferenceNumber" +"Value": "006825.4" } +"nil": false +"globalScope": true +"typeSubstituted": false } ] } } 1 => {#5715 +"Amount": 132.0 +"LinkedTxn": array:1 [ 0 => {#5714 +"TxnId": "206" +"TxnType": "Invoice" } ] +"LineEx": {#5713 +"any": array:3 [ 0 => {#5712 +"name": "{http://schema.intuit.com/finance/v3}NameValue" +"declaredType": "com.intuit.schema.finance.v3.NameValue" +"scope": "javax.xml.bind.JAXBElement$GlobalScope" +"value": {#5711 +"Name": "txnId" +"Value": "206" } +"nil": false +"globalScope": true +"typeSubstituted": false } 1 => {#5710 +"name": "{http://schema.intuit.com/finance/v3}NameValue" +"declaredType": "com.intuit.schema.finance.v3.NameValue" +"scope": "javax.xml.bind.JAXBElement$GlobalScope" +"value": {#5709 +"Name": "txnOpenBalance" +"Value": "132.00" } +"nil": false +"globalScope": true +"typeSubstituted": false } 2 => {#5708 +"name": "{http://schema.intuit.com/finance/v3}NameValue" +"declaredType": "com.intuit.schema.finance.v3.NameValue" +"scope": "javax.xml.bind.JAXBElement$GlobalScope" +"value": {#5707 +"Name": "txnReferenceNumber" +"Value": "006813" } +"nil": false +"globalScope": true +"typeSubstituted": false } ] } } ] } ] +"startPosition": 1 +"maxResults": 1 } +"time": "2023-05-12T22:20:40.937-07:00" } */ final class Payment extends Model { use CompareAttributes; public function __get($key) { $keymap = [ 'id' => 'Id', 'synctoken' => 'SyncToken', 'date_paid' => 'TxnDate', 'total_amt' => 'TotalAmt', 'unapplied' => 'UnappliedAmt', ]; switch ($key) { case 'created_at': return object_get($this->getAttribute('MetaData'),'CreateTime'); case 'updated_at': return object_get($this->getAttribute('MetaData'),'LastUpdatedTime'); case 'account_ref': return object_get($this->getAttribute('CustomerRef'),'value'); default: return parent::__get(Arr::get($keymap,$key,$key)); } } public function lines(): Collection { $result = collect($this->getAttribute('Line'))->transform(function($item) { return $item->LinkedTxn[0]->TxnType === 'Invoice' ? [ $item->LinkedTxn[0]->TxnId => $item->Amount] : []; }); return collect(array_replace(...$result)); } }