<?php if ($showLabel && $showField) : ?>
    <?php if ($options['wrapper'] !== false) : ?>
    <div <?= $options['wrapperAttrs'] ?> >
    <?php endif; ?>
<?php endif; ?>

<?php if ($showLabel && $options['label'] !== false && $options['label_show']) : ?>
    <?= Form::customLabel($name, $options['label'], $options['label_attr']) ?>
<?php endif; ?>

<?php if ($showField) : ?>
    <?php if (isset($options['form_horizontal']) && $options['form_horizontal'] == true && $type !== 'hidden') : ?><div class="col-sm-9"><?php endif; ?>
    <?php if (isset($options['attr']['readonly']) && $options['attr']['readonly'] === true) : ?>
    <?php else : ?>
        <?php $inputClass = \Illuminate\Support\Arr::get($options, 'attr.class', 'form-control'); ?>
        <?php \Illuminate\Support\Arr::set($options, 'attr.class', $inputClass . ' filestyle'); ?>
        <?= Form::input($type, $name, $options['value'], $options['attr']) ?>
    <?php endif; ?>

    <?php
        $disk = $options['disk'] ?? 'local';
        $path = $options['path'] ?? '/';
        $file = $options['value'];
        $filepath = $path . '/' . $file;
    ?>

    <?php if (! empty($file) && Storage::disk($disk)->has($filepath)) : ?>
      <p style="padding-top: 7px;">Current: <a href="<?= url(Storage::disk($disk)->url($filepath)) ?>" target="_blank"><?= $file ?></a></p>
    <?php else : ?>
        <?php if (isset($options['attr']['readonly']) && $options['attr']['readonly'] === true) : ?>
        <p style="padding-top: 7px;">None</p>
        <?php endif; ?>
    <?php endif ?>

    <?php include 'help_block.php' ?>
    <?php if (isset($options['form_horizontal']) && $options['form_horizontal'] == true && $type !== 'hidden') : ?></div><?php endif; ?>
<?php endif; ?>

<?php include 'errors.php' ?>

<?php if ($showLabel && $showField) : ?>
    <?php if ($options['wrapper'] !== false) : ?>
    </div>
    <?php endif; ?>
<?php endif; ?>
