

<?php
    $fieldClass = $class ?? 'form-select';
    $fieldRequired = $required ?? false;
    $fieldPlaceholder = $placeholder ?? 'Select Unit';
    $fieldSelected = $selected ?? '';
    $isEdit = $isEdit ?? false;
    $disabled = $disabled ?? false;


    // $defaultUnits = [
    //     'meters' => 'Meters',
    //     'pieces' => 'Pieces',
    //     'kg' => 'Kilograms',
    //     'tons' => 'Tons',
    //     'liters' => 'Liters',
    //     'boxes' => 'Boxes',
    //     'rolls' => 'Rolls',
    //     'coils' => 'Coils',
    //     'pcs' => 'Pieces',
    //     'm' => 'Meters',
    //     'l' => 'Liters',
    //     'g' => 'Grams',
    //     'mg' => 'Milligrams',
    //     'cm' => 'Centimeters',
    //     'mm' => 'Millimeters',
    //     'ft' => 'Feet',
    //     'in' => 'Inches',
    //     'yd' => 'Yards',
    //     'sqm' => 'Square Meters',
    //     'cbm' => 'Cubic Meters',
    //     'dozen' => 'Dozen',
    //     'gross' => 'Gross',
    //     'ream' => 'Ream',
    //     'set' => 'Set',
    //     'pair' => 'Pair',
    //     'bundle' => 'Bundle',
    //     'pack' => 'Pack',
    //     'carton' => 'Carton',
    //     'pallet' => 'Pallet',
    //     'drum' => 'Drum',
    //     'barrel' => 'Barrel',
    //     'bag' => 'Bag',
    //     'sack' => 'Sack',
    //     'tube' => 'Tube',
    //     'sheet' => 'Sheet',
    //     'plate' => 'Plate',
    //     'rod' => 'Rod',
    //     'wire' => 'Wire',
    //     'cable' => 'Cable',
    //     'strand' => 'Strand',
    //     'conductor' => 'Conductor',
    //     'insulation' => 'Insulation',
    //     'jacket' => 'Jacket',
    //     'core' => 'Core',
    //     'twist' => 'Twist',
    //     'bunch' => 'Bunch',
    //     'lay' => 'Lay',
    //     'pitch' => 'Pitch',
    //     'diameter' => 'Diameter',
    //     'gauge' => 'Gauge',
    //     'awg' => 'AWG',
    //     'mm2' => 'Square Millimeters',
    //     'cm2' => 'Square Centimeters',
    //     'm2' => 'Square Meters',
    //     'mm3' => 'Cubic Millimeters',
    //     'cm3' => 'Cubic Centimeters',
    //     'm3' => 'Cubic Meters',
    // ];
    // Get default units from database if not provided
    $defaultUnits = \App\Models\Uom::orderBy('name')->pluck('name', 'code')->toArray();

    $unitsToUse = $units ?? $defaultUnits;
?>

<select
    name="<?php echo e($name); ?>"
    class="<?php echo e($fieldClass); ?> <?php $__errorArgs = [$name];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
    <?php if($fieldRequired): ?> required <?php endif; ?>
    <?php if($isEdit): ?> data-edit="true" <?php endif; ?>
    <?php if($disabled): ?> disabled <?php endif; ?>
>
    <option value=""><?php echo e($fieldPlaceholder); ?></option>
    <?php $__currentLoopData = $unitsToUse; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <option value="<?php echo e($value); ?>" <?php echo e($fieldSelected == $value ? 'selected' : ''); ?>>
            <?php echo e($label); ?>

        </option>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>

<?php $__errorArgs = [$name];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
    <div class="invalid-feedback"><?php echo e($message); ?></div>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
<?php /**PATH C:\laragon\www\habibcables-ERP\resources\views/common/unit-select.blade.php ENDPATH**/ ?>