app/Utils/Util.php
/**
     * Defines available Payment Types
     *
     * @return array
     */
Defines available Payment Types
@return array
Defines available Payment Types @return array
public function payment_types($location = null)
    {
        $payment_types = ['cash' => __('lang_v1.cash'), 'card' => __('lang_v1.card'), 'cheque' => __('lang_v1.cheque'), 'bank_transfer' => __('lang_v1.bank_transfer'), 'other' => __('lang_v1.other')];
        $custom_labels = !empty(session('business.custom_labels')) ? json_decode(session('business.custom_labels'), true) : [];
        $payment_types['custom_pay_1'] = !empty($custom_labels['payments']['custom_pay_1']) ? $custom_labels['payments']['custom_pay_1'] : __('lang_v1.custom_payment_1');
        $payment_types['custom_pay_2'] = !empty($custom_labels['payments']['custom_pay_2']) ? $custom_labels['payments']['custom_pay_2'] : __('lang_v1.custom_payment_2');
        $payment_types['custom_pay_3'] = !empty($custom_labels['payments']['custom_pay_3']) ? $custom_labels['payments']['custom_pay_3'] : __('lang_v1.custom_payment_3');
        if (!empty($location)) {
            $location = is_object($location) ? $location : BusinessLocation::find($location);
            $location_account_settings = !empty($location->default_payment_accounts) ? json_decode($location->default_payment_accounts, true) : [];
            $enabled_accounts = [];
            foreach ($location_account_settings as $key => $value) {
                if (!empty($value['is_enabled'])) {
                    $enabled_accounts[] = $key;
                }
            }
            foreach ($payment_types as $key => $value) {
                if (!in_array($key, $enabled_accounts)) {
                    unset($payment_types[$key]);
                }
            }
        }
        return $payment_types;
    }
public function payment_types ( $ location = null ) { $ payment_types = [ 'cash' => __ ( 'lang_v1.cash' ) , 'card' => __ ( 'lang_v1.card' ) , 'cheque' => __ ( 'lang_v1.cheque' ) , 'bank_transfer' => __ ( 'lang_v1.bank_transfer' ) , 'other' => __ ( 'lang_v1.other' ) ] ; $ custom_labels = ! empty ( session ( 'business.custom_labels' ) ) ? json_decode ( session ( 'business.custom_labels' ) , true ) : [ ] ; $ payment_types [ 'custom_pay_1' ] = ! empty ( $ custom_labels [ 'payments' ] [ 'custom_pay_1' ] ) ? $ custom_labels [ 'payments' ] [ 'custom_pay_1' ] : __ ( 'lang_v1.custom_payment_1' ) ; $ payment_types [ 'custom_pay_2' ] = ! empty ( $ custom_labels [ 'payments' ] [ 'custom_pay_2' ] ) ? $ custom_labels [ 'payments' ] [ 'custom_pay_2' ] : __ ( 'lang_v1.custom_payment_2' ) ; $ payment_types [ 'custom_pay_3' ] = ! empty ( $ custom_labels [ 'payments' ] [ 'custom_pay_3' ] ) ? $ custom_labels [ 'payments' ] [ 'custom_pay_3' ] : __ ( 'lang_v1.custom_payment_3' ) ; if ( ! empty ( $ location ) ) { $ location = is_object ( $ location ) ? $ location : BusinessLocation :: find ( $ location ) ; $ location_account_settings = ! empty ( $ location -> default_payment_accounts ) ? json_decode ( $ location -> default_payment_accounts , true ) : [ ] ; $ enabled_accounts = [ ] ; foreach ( $ location_account_settings as $ key => $ value ) { if ( ! empty ( $ value [ 'is_enabled' ] ) ) { $ enabled_accounts [ ] = $ key ; } } foreach ( $ payment_types as $ key => $ value ) { if ( ! in_array ( $ key , $ enabled_accounts ) ) { unset ( $ payment_types [ $ key ] ) ; } } } return $ payment_types ; }
Defines available Payment Types
 @return array
Defines available Payment Types @return array
//Unset payment types if not enabled in business location