'payments' => [
],
]);
- if ($response['status'] == LPTrackerApi::SUCCESS_STATUS) {
- SentKogort::updateAll(['status' => SentKogort::SUCCESS_UPLOAD_TO_LPTRACKER_STATUS], ['id' => $number->id]);
- } else {
- SentKogort::updateAll(['status' => SentKogort::ERROR_UPLOAD_TO_LPTRACKER_STATUS], ['id' => $number->id]);
- throw new \Exception("ОШИБКА С LPTRACKER\n" . implode('. ', array_map(fn($error) => $error['message'], $response['errors'])));
+
+ $status = $response['status'] == LPTrackerApi::SUCCESS_STATUS
+ ? SentKogort::SUCCESS_UPLOAD_TO_LPTRACKER_STATUS
+ : SentKogort::ERROR_UPLOAD_TO_LPTRACKER_STATUS;
+
+ SentKogort::updateAll(['status' => $status], ['id' => $number->id]);
+
+ if ($status === SentKogort::ERROR_UPLOAD_TO_LPTRACKER_STATUS) {
+ throw new \Exception(
+ "ОШИБКА С LPTRACKER\n" . implode('. ', array_column($response['errors'], 'message'))
+ );
}
}
} catch (\Exception $exception) {