getChanges(); $ignored = ['updated_at']; $changedFields = array_filter( array_keys($changes), fn ($key) => !in_array($key, $ignored) ); if (empty($changedFields)) { return; } ShipmentUpdatedNotification::notify($shipment); $oldStatus = $shipment->getOriginal('status'); $newStatus = $shipment->status; if ($oldStatus !== $newStatus) { $trackingUrl = url("/track/{$shipment->awb_no}"); $smsEnabled = !empty(SystemSetting::get('kavenegar_api_key')); if ($smsEnabled && $newStatus === \App\Enums\ShipmentStatus::Approved && (bool) SystemSetting::get('kavenegar_send_shipment_approved', true)) { $shipment->user->notify(new ShipmentApprovedSms($shipment->awb_no, $trackingUrl)); } if ($smsEnabled && $newStatus === \App\Enums\ShipmentStatus::Cancelled && (bool) SystemSetting::get('kavenegar_send_shipment_rejected', true)) { $shipment->user->notify(new ShipmentRejectedSms($shipment->awb_no, 'سفارش شما رد شد.')); } } } }