@forelse ($trucks as $k => $t)
@php
$trip = $t->activeTrip;
$state = $trip ? ($trip->is_overdue ? 'late' : 'loaded') : 'empty';
$region = $trip ? '' : ($t->current_region ?: 'غير محدد');
$search = strtolower($t->plate_number . ' ' . $t->truck_type . ' ' . \App\Models\truck_trip::ownershipLabel($t->ownership) . ' ' . ($trip ? $trip->driver_name . ' ' . optional($trip->driver)->phone . ' ' . $trip->from_region . ' ' . $trip->to_region . ' ' . $trip->load_type . ' ' . $trip->customer_name : $region . ' ' . optional($t->default_driver)->name . ' ' . optional($t->default_driver)->phone));
@endphp
{{ $t->truck_type ?: 'شاحنة' }}{{ $t->total_load ? ' · ' . $t->total_load : '' }}
@if ($t->insurance_status == 'expired' || $t->insurance_status == 'soon' || $t->istimara_status == 'expired' || $t->istimara_status == 'soon')
@if ($t->insurance_status == 'expired') التأمين منتهي
@elseif ($t->insurance_status == 'soon') التأمين ينتهي {{ $t->insurance_expiry->format('Y/m/d') }}@endif
@if ($t->istimara_status == 'expired') الاستمارة منتهية
@elseif ($t->istimara_status == 'soon') الاستمارة تنتهي {{ $t->istimara_expiry->format('Y/m/d') }}@endif
@endif
{{ \App\Models\truck_trip::ownershipLabel($t->ownership) }}
@if ($state == 'empty') فاضية
@elseif ($state == 'late') متأخرة
@else محمّلة @endif
@if (!$trip)
{{ $region }}{{ $t->current_city ? ' - ' . $t->current_city : '' }}
@include('trucks._call', ['drv' => $t->default_driver, 'name' => null, 'phone' => null])
@else
من{{ $trip->from_region }}{{ $trip->from_city }}
إلى{{ $trip->to_region }}{{ $trip->to_city }}
@include('trucks._call', ['drv' => $trip->driver, 'name' => $trip->driver_name, 'phone' => null])
@endif