

<?php $__env->startSection('title', 'Banners'); ?>

<?php $__env->startSection('content'); ?>
<div class="admin-page-header">
    <h1>Homepage Banners</h1>
    <div>
        <?php
            $bannerCount = \App\Models\Banner::count();
        ?>
        <?php if($bannerCount < 3): ?>
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('banners.create')): ?>
            <a href="<?php echo e(route('admin.banners.create')); ?>" class="admin-btn-primary">
                <i class="bi bi-plus"></i> Add Banner (<?php echo e($bannerCount); ?>/3)
            </a>
            <?php endif; ?>
        <?php else: ?>
            <span class="badge-modern badge-modern-warning">Maximum limit reached (3/3)</span>
        <?php endif; ?>
    </div>
</div>

<div class="admin-card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="admin-table table table-hover">
                <thead>
                    <tr>
                        <th>Image</th>
                        <th>Title</th>
                        <th>Link</th>
                        <th>Sort Order</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__currentLoopData = $banners; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $banner): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td>
                                <?php if($banner->image_path): ?>
                                    <img src="<?php echo e(asset('storage/' . $banner->image_path)); ?>" alt="<?php echo e($banner->title); ?>" class="admin-image-preview" style="width: 150px; height: 80px; object-fit: cover;">
                                <?php else: ?>
                                    <div class="bg-secondary rounded d-flex align-items-center justify-content-center admin-image-preview" style="width: 150px; height: 80px;">
                                        <i class="bi bi-image text-white"></i>
                                    </div>
                                <?php endif; ?>
                            </td>
                            <td><?php echo e($banner->title ?? '-'); ?></td>
                            <td>
                                <?php if($banner->link): ?>
                                    <a href="<?php echo e($banner->link); ?>" target="_blank"><?php echo e(\Illuminate\Support\Str::limit($banner->link, 30)); ?></a>
                                <?php else: ?>
                                    <span class="text-muted">-</span>
                                <?php endif; ?>
                            </td>
                            <td><?php echo e($banner->sort_order); ?></td>
                            <td>
                                <span class="badge-modern <?php echo e($banner->is_active ? 'badge-modern-success' : 'badge-modern-danger'); ?>">
                                    <?php echo e($banner->is_active ? 'Active' : 'Inactive'); ?>

                                </span>
                            </td>
                            <td>
                                <div class="d-flex gap-2">
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('banners.update')): ?>
                                    <a href="<?php echo e(route('admin.banners.edit', $banner->id)); ?>" class="admin-action-btn admin-action-btn-sm admin-btn-primary">
                                        <i class="bi bi-pencil"></i> Edit
                                    </a>
                                    <?php endif; ?>
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('banners.delete')): ?>
                                    <form action="<?php echo e(route('admin.banners.destroy', $banner->id)); ?>" method="POST" class="d-inline" onsubmit="return confirm('Are you sure?')">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="admin-action-btn admin-action-btn-sm" style="background: #ef4444; height: -webkit-fill-available; color: white;">
                                            <i class="bi bi-trash"></i> Delete
                                        </button>
                                    </form>
                                    <?php endif; ?>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>

        <?php if($banners->hasPages()): ?>
        <div class="pagination-wrapper mt-4">
            <div class="d-flex justify-content-end align-items-center gap-3 flex-wrap">
                <div class="pagination-info-text">
                    Showing <strong><?php echo e($banners->firstItem() ?? 0); ?></strong>–<strong><?php echo e($banners->lastItem() ?? 0); ?></strong> 
                    of <strong><?php echo e($banners->total()); ?></strong> banners
                </div>
                <div class="pagination-controls">
                    <?php echo e($banners->links('vendor.pagination.admin-categories')); ?>

                </div>
            </div>
        </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/shaa_jewels/live/resources/views/admin/banners/index.blade.php ENDPATH**/ ?>