🔄 در حال انجام: تست دستی Filament ⏸️ بلاک: مهاجرت ۳۹۵۰ رکورد (منتظر فایل اکسل اصلاحشده) ⏸️ بلاک: پلاگین وردپرس (بعد از تست کامل API)
37 lines
908 B
PHP
37 lines
908 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\Shipment;
|
|
use App\Models\ShipmentTrackingEvent;
|
|
|
|
class TrackingService
|
|
{
|
|
public function getTrackingTimeline(string $awb_no)
|
|
{
|
|
$shipment = Shipment::where('awb_no', $awb_no)->firstOrFail();
|
|
|
|
return $shipment->trackingEvents()
|
|
->orderByDesc('event_date')
|
|
->orderByDesc('event_time')
|
|
->get();
|
|
}
|
|
|
|
public function addTrackingEvent(int $shipment_id, array $data): ShipmentTrackingEvent
|
|
{
|
|
return ShipmentTrackingEvent::create(array_merge($data, [
|
|
'shipment_id' => $shipment_id,
|
|
'source' => 'manual',
|
|
]));
|
|
}
|
|
|
|
public function getShipmentWithTracking(string $awb_no)
|
|
{
|
|
$shipment = Shipment::where('awb_no', $awb_no)
|
|
->with(['carrierMappings', 'trackingEvents'])
|
|
->firstOrFail();
|
|
|
|
return $shipment;
|
|
}
|
|
}
|