<?php if (!empty($slides)): ?>
    <div class="modal fade show" tabindex="-1" role="dialog" id="slides-modal"
         data-interval="<?= config('slides.modal.interval', 60*60*60) ?>"
         data-slides-interval="<?= config('slides.modal.slides_interval', 5) ?>"
    >
        <div class="modal-dialog slides-container" role="document">
            <?php foreach ($slides as $slide): ?>
                <div class="modal-content slide-modal">
                    <div class="modal-header">
                        <h5 class="modal-title"><?= $slide['title'] ?></h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                    <div class="modal-body">
                        <?php if (empty($slide['url'])): ?>
                            <img class="img-fluid" alt="<?= $slide['title'] ?>" src="<?= upload_to('/slides/' . $slide['image']) ?>" />
                        <?php else: ?>
                            <a target="_blank" href="<?= $slide['url'] ?>">
                                <img class="img-fluid" alt="<?= $slide['title'] ?>" src="<?= upload_to('/slides/' . $slide['image']) ?>" />
                            </a>
                        <?php endif ?>
                    </div>

                    <div class="modal-footer">
                        <?php foreach (json_decode($slide['links'], true) ?? [] as $link): ?>
                            <a data-ajax href="<?= $link['link'] ?>" class="btn btn-info"><?= $link['name'] ?></a>
                        <?php endforeach ?>
                        <a data-ajax href="#" class="btn btn-info" data-dismiss="modal"><?= __('Close') ?></a>
                    </div>
                </div>
            <?php endforeach ?>

            <div class="slides-control">
                <?php foreach ($slides as $index => $slide): ?>
                    <a href="#" data-index="<?= $index ?>" class="slide-control slide-control-<?= $index ?> <?= $index === 0 ? 'active' : '' ?>"> </a>
                <?php endforeach ?>
            </div>
        </div>
    </div>
<?php endif ?>