@foreach($shipments as $shipment) @php $itemRows = $shipment->items; $itemCount = $itemRows->count() > 0 ? $itemRows->count() : ($shipment->item_name ? 1 : 0); $itemLines = $itemRows->map(function ($item) { $name = trim((string) $item->item_name); if ($name === '') { return null; } $qty = (float) $item->unit_quantity; if ($qty > 1) { $qtyText = abs($qty - round($qty)) < 0.001 ? (string) (int) round($qty) : rtrim(rtrim(number_format($qty, 2, '.', ''), '0'), '.'); return $name.' ('.$qtyText.')'; } return $name; })->filter()->values(); if ($itemLines->isEmpty()) { $itemLines = collect([$shipment->item_name ?: 'N/A']); } $arrived = $shipment->received_at ? ($shipment->received_at->isToday() ? 'Arrived Today, '.$shipment->received_at->format('h:i A') : 'Arrived '.$shipment->received_at->format('d M Y, h:i A')) : 'Arrival time unavailable'; $streamLabel = method_exists($shipment, 'customsShipmentStreamLabel') ? $shipment->customsShipmentStreamLabel() : 'N/A'; $portBadge = $shipment->port_of_destination === 'male' ? 'Male' : ($shipment->port_of_destination === 'rest' ? 'Rest of Maldives' : ''); $cargoBadge = in_array($shipment->cargo_type, ['ecommerce', 'assisted', 'walkin'], true) ? $shipment->cargoTypeLabel() : ''; @endphp
{{ $shipment->sender_name ?: 'Shipment' }} {{ $shipment->tracking_number ?: 'N/A' }} • {{ $arrived }} @if($streamLabel !== 'N/A'){{ $streamLabel }}@endif @if($portBadge !== ''){{ $portBadge }}@endif @if($cargoBadge !== ''){{ $cargoBadge }}@endif @foreach($itemLines as $itemLine) {{ $itemLine }} @endforeach Items {{ $itemCount }} @if($shipment->weight)Dead Wt: {{ $shipment->weight }}@endif @if($shipment->dimensions){{ $shipment->dimensions }}@endif Declared value ₹{{ number_format((float) $shipment->declared_value_inr, 2) }} ${{ number_format((float) $shipment->declared_value, 2) }}
@endforeach