jaseofspades88
$call = App\Models\Api\Call::find(3);
dd(
collect(unserialize($call->response))->map(function ($item) {
// return $item;
return [
'name' => $item['service_name'],
'total_value' => $item['total_value']->getAmount(),
'base_charge' => [
'amount' => $item['base_charge']['amount']->getAmount(),
'vat' => $item['base_charge']['vat']->getAmount(),
],
'fuel_charge' => [
'amount' => $item['fuel_charge']['amount']->getAmount(),
'vat' => $item['fuel_charge']['vat']->getAmount(),
],
'item_charges' => collect($item['item_charges'])->map(function (
$charge
) {
return [
'name' => $charge['name'],
'amount' => $charge['amount']->getAmount(),
'vat' => $charge['vat']->getAmount(),
];
})->toArray(),
'other_charges' => collect($item['other_charges'])->map(function (
$charge
) {
return [
'name' => $charge['name'],
'amount' => $charge['amount']->getAmount(),
'vat' => $charge['vat']->getAmount(),
];
})->toArray(),
];
})
);
Illuminate\Support\Collection {#1475
#items: array:5 [
0 => array:6 [
"name" => "EXPRESS 9:00 NONDOC"
"total_value" => "7164"
"base_charge" => array:2 [
"amount" => "4702"
"vat" => "0"
]
"fuel_charge" => array:2 [
"amount" => "782"
"vat" => "0"
]
"item_charges" => array:1 [
0 => array:3 [
"name" => "EMERGENCY SITUATION"
"amount" => "180"
"vat" => "0"
]
]
"other_charges" => array:1 [
0 => array:3 [
"name" => "9:00 PREMIUM"
"amount" => "1500"
"vat" => "0"
]
]
]
1 => array:6 [
"name" => "EXPRESS 12:00 NONDOC"
"total_value" => "6041"
"base_charge" => array:2 [
"amount" => "4702"
"vat" => "0"
]
"fuel_charge" => array:2 [
"amount" => "659"
"vat" => "0"
]
"item_charges" => array:1 [
0 => array:3 [
"name" => "EMERGENCY SITUATION"
"amount" => "180"
"vat" => "0"
]
]
"other_charges" => array:1 [
0 => array:3 [
"name" => "12:00 PREMIUM"
"amount" => "500"
"vat" => "0"
]
]
]
2 => array:6 [
"name" => "MEDICAL EXPRESS"
"total_value" => "16467"
"base_charge" => array:2 [
"amount" => "14670"
"vat" => "0"
]
"fuel_charge" => array:2 [
"amount" => "1797"
"vat" => "0"
]
"item_charges" => []
"other_charges" => []
]
3 => array:6 [
"name" => "EXPRESS WORLDWIDE NONDOC"
"total_value" => "5480"
"base_charge" => array:2 [
"amount" => "4702"
"vat" => "0"
]
"fuel_charge" => array:2 [
"amount" => "598"
"vat" => "0"
]
"item_charges" => array:1 [
0 => array:3 [
"name" => "EMERGENCY SITUATION"
"amount" => "180"
"vat" => "0"
]
]
"other_charges" => []
]
4 => array:6 [
"name" => "ECONOMY SELECT NONDOC"
"total_value" => "2518"
"base_charge" => array:2 [
"amount" => "2337"
"vat" => "0"
]
"fuel_charge" => array:2 [
"amount" => "181"
"vat" => "0"
]
"item_charges" => []
"other_charges" => []
]
]
}