<?php

namespace Opencart\Catalog\Model\Extension\Alsendo\Module;

use Opencart\System\Engine\Model;
use Opencart\System\Engine\Registry;

class PaymentShipment extends Model {
    public function __construct(Registry $registry) {
        parent::__construct($registry);
    }

    public function getPaymentsForShipmentMap(): array {
        $result = [];

        $query = $this->db->query("SELECT `shipping_method_id`, `payment_extension_id` FROM `" . DB_PREFIX . "alsendo_payment_shipment`");

        foreach ($query->rows as $row) {
            $shipmentId = (int)$row['shipping_method_id'];
            $paymentId = (int)$row['payment_extension_id'];

            if (!isset($result[$shipmentId])) {
                $result[$shipmentId] = [];
            }

            $result[$shipmentId][] = $paymentId;
        }

        return $result;
    }

}