<table class="table table-sm table-bordered table-hover">
    <thead>
        <tr class="table-warning">
            <th>#</th>
            <th>SKU</th>
            <th>Barang</th>
            <?php foreach ($pivot_data['gudang'] as $gudang): ?>
                <th><?= $gudang; ?></th>
            <?php endforeach; ?>
        </tr>
    </thead>
    <tbody>
        <?php
        $i = 1;
        foreach ($pivot_data['barang'] as $index => $barang): ?>
            <tr>
                <td><?= $i; ?></td>
                <td><?= $pivot_data['sku'][$index]; ?></td>
                <td><?= $barang; ?></td>
                <?php foreach ($pivot_data['stok'][$index] as $stok): ?>
                    <td style='text-align: right;'><?= $stok; ?></td>
                <?php endforeach; ?>
            </tr>
        <?php $i++;
        endforeach; ?>
    </tbody>
</table>