Level 1
Fixed it myself, solution below;
$packing = packingDetails::where('file', $this->file->id)->get()->toArray();
$arrayLength = count($packing);
$i = 0;
while ($i < $arrayLength) {
$items[] = [
'contents' => $packing[$i]['line'],
"value" => $packing[$i]['shipmentValue'],
"weight" => $packing[$i]['shipmentWeight'],
"length" => $packing[$i]['shipmentLenght'],
"width" => $packing[$i]['shipmentWidth'],
"height" => $packing[$i]['shipmentHeight'],
"hs_code" => $packing[$i]['hsCode'],
];
$i++;
}
And then in the request;
"items" => $items
)
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);