diff --git a/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php b/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php index 9861b78f..791c0de3 100644 --- a/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php @@ -65,6 +65,18 @@ class ExportsAnalyticBookingTransactions implements FromQuery, WithHeadings, Wit $companyType[companyType::PERSONAL_BUSINESS] = 'PERSONAL_BUSINESS'; $payments = $booking->transactions()->where('type', 1)->whereIn('status', [2, 3]); + + $paymentmethondArray = PaymentMethodType::PAYMENT_METHODS_ID; + $paymentmethondArray[0] = 'Hybrid'; + $paymentMethod = ''; + foreach ($payments->get() as $payment) { + if ( $paymentMethod == '' ) { + $paymentMethod = $payment->payment_method; + } else if ( $payment->payment_method != $paymentMethod ) { + $paymentMethod = 0; // set it to Hybrid + } + } + $paymentMethod === '' ? '' : $paymentMethod = $paymentmethondArray[$paymentMethod]; $firstPayment = $payments->first(); @@ -74,23 +86,6 @@ class ExportsAnalyticBookingTransactions implements FromQuery, WithHeadings, Wit $lastPayment = $booking->transactions()->where('type', 1)->whereIn('status', [2, 3])->orderBy('id', 'desc')->first(); - $paymentMethod = ''; - foreach ($payments->get() as $payment) { - - if ( $paymentMethod == '' ) { - $paymentMethod = $payment->payment_method; - } else { - if ( $payment->payment_method != $paymentMethod ) { - $paymentMethod = 0; // set it to Hybrid - } - } - } - - $paymentmethondArray = PaymentMethodType::PAYMENT_METHODS_ID; - $paymentmethondArray[0] = 'Hybrid'; - - $paymentMethod == '' ? '' : $paymentMethod = $paymentmethondArray[$paymentMethod]; - return [ $booking->id, $booking->company_id,