@if($shipments->isEmpty())
No shipments found

No shipments match your search criteria.

@else
@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; $qtyText = abs($qty - round($qty)) < 0.001 ? (string) (int) round($qty) : rtrim(rtrim(number_format($qty, 2, '.', ''), '0'), '.'); return $name.' ('.($qtyText === '' ? '0' : $qtyText).')'; })->filter()->values(); if ($itemLines->isEmpty()) { $itemLines = collect([$shipment->item_name ?: '—']); } $itemParts = $itemLines->implode(' '); $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'; $photoCount = $shipment->relationLoaded('photos') ? $shipment->photos->count() : $shipment->photos()->count(); $weightText = trim((string) $shipment->weight) !== '' ? $shipment->weight : '—'; $dimensionText = trim((string) $shipment->dimensions); $dimensionLabel = $dimensionText !== '' ? $dimensionText : 'Dims: Pending'; $streamLabel = $shipment->customsShipmentStreamLabel(); $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() : ''; $declaredInr = (float) $shipment->declared_value_inr; $declaredUsd = (float) $shipment->declared_value; $customerName = optional($shipment->kuser)->name ?: ''; $suiteText = trim((string) $shipment->suite_number); $suiteAddress = $shipment->virtualAddress; $deliveryBadges = $suiteAddress ? $suiteAddress->deliveryBadges() : [ 'name' => $customerName !== '' ? $customerName : '—', 'phone' => '—', 'label' => '—', 'address' => '—', ]; $popId = 'ship-pop-'.$shipment->id; $viewUrl = route('wuser.shipments.show', \Illuminate\Support\Facades\Crypt::encrypt($shipment->id)); $photoUrls = ($shipment->relationLoaded('photos') ? $shipment->photos : collect())->map(function ($photo) { $path = trim((string) $photo->photo_path); if ($path === '') { return null; } try { return \Illuminate\Support\Facades\Storage::disk('s3')->url($path); } catch (\Throwable $e) { return null; } })->filter()->values(); $storeMarks = collect($shipment->assistedPurchasePaymentIds())->flatMap(function ($paymentId) use ($storeMarksByPayment) { return ($storeMarksByPayment ?? collect())->get($paymentId, collect()); })->unique('store')->values(); $searchText = strtolower(implode(' ', array_filter([ $shipment->sender_name, $shipment->tracking_number, $shipment->suite_number, optional($shipment->kuser)->name, $itemParts, $shipment->status, $streamLabel, $portBadge, $cargoBadge, $weightText, $dimensionLabel, $arrived, ]))); @endphp {{ $customerName !== '' ? $customerName : 'No customer' }} Suite {{ $suiteText !== '' ? $suiteText : 'N/A' }} @if($portBadge !== ''){{ $portBadge }}@endif @if($photoUrls->isNotEmpty()) @foreach($photoUrls as $photoUrl) Shipment photo @endforeach @endif @include('wuser.partials.delivery-badges', ['badges' => $deliveryBadges, 'popId' => $popId, 'suiteLine' => $suiteText]) @foreach($storeMarks as $storeMark) {{ $storeMark['store'] }} @endforeach {{ $shipment->sender_name ?: 'Shipment' }} {{ $shipment->tracking_number ?: 'N/A' }} @if($streamLabel !== 'N/A'){{ $streamLabel }}@endif @if($cargoBadge !== ''){{ $cargoBadge }}@endif @foreach($itemLines as $itemLine) {{ $itemLine }} @endforeach {{ $arrived }} Items {{ $itemCount }} Dead Wt: {{ $weightText }} {{ $dimensionLabel }} {{ $photoCount }} {{ $photoCount === 1 ? 'Photo' : 'Photos' }} Declared value ₹{{ number_format($declaredInr, 2) }} ${{ number_format($declaredUsd, 2) }} @endforeach
@endif