mardi 19 janvier 2021

Stored Session in Laravel

I want to stored the addrId only. But I'm having trouble to get that. Below is my array;

"customerInfo" => array:1 [▼
    "accountList" => {#1810 ▼
      +"511000000012015": array:1 [▼
        0 => {#1821 ▼
          +"accountBasicInfo": {#1761 ▶}
          +"contactPersonInfo": {#1817 ▼
            +"contactPersonId": "511000000005007"
            +"addressInfo": {#1818 ▼
              +"addrId": "511000000009029"
              +"addr1": "S"
              +"addr2": []
              +"postalCode": "16390"
            }
          }
        }
      ]
      +"511000000012023": array:1 [▶]

Here is my code. The getResp are calling from API.

/** Initial Response */
$accountList = $addrList = [];

$response['accountList'] = $accountList = $getResp->data;
session()->put('customerInfo.accountList', $accountList);

I'm trying todo like this one, but it wont work. How can I solve it? Currently the addressInfo just return for 511000000012015 but not the next one. I'm stuck to get the session. Please help. Thank you

foreach(session()->get('customerInfo.accountList') as $keys => $addrList) {
    session()->put('customerInfo.addressInfo.addressID', $addrList[0]
    ->contactPersonInfo->addressInfo->addrId);
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire