

<?php $__env->startSection('backend_content'); ?>
    <div class="p-4">
        <?php if(!empty($tableMissing)): ?>
            <div class="alert alert-warning mb-3">
                Contact messages table is missing. Run <code>php artisan migrate</code> to enable message storage.
            </div>
        <?php endif; ?>

        <div class="d-flex align-items-center justify-content-between mb-3 flex-wrap gap-2">
            <h4 class="mb-0">Contact Messages</h4>
            <span class="badge bg-label-primary"><?php echo e($messages->total()); ?> total</span>
        </div>

        
        <form method="GET" action="<?php echo e(route('admin.contact-messages.index')); ?>" class="mb-3 d-flex gap-2">
            <input type="text" name="search" class="form-control" placeholder="Search by name, email, phone or message…"
                value="<?php echo e($search); ?>" style="max-width:360px;">
            <button type="submit" class="btn btn-primary">Search</button>
            <?php if($search): ?>
                <a href="<?php echo e(route('admin.contact-messages.index')); ?>" class="btn btn-outline-secondary">Clear</a>
            <?php endif; ?>
        </form>

        <div class="table-responsive">
            <table class="table table-hover align-middle">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Phone</th>
                        <th>Shop</th>
                        <th>Message</th>
                        <th>Received</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $messages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $message): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($loop->iteration + ($messages->currentPage() - 1) * $messages->perPage()); ?></td>
                            <td><?php echo e($message->name); ?></td>
                            <td>
                                <a href="mailto:<?php echo e($message->email); ?>"><?php echo e($message->email); ?></a>
                            </td>
                            <td><?php echo e($message->phone ?: '-'); ?></td>
                            <td><?php echo e(optional($message->shop)->name ?: '-'); ?></td>
                            <td style="min-width:240px; white-space:normal;"><?php echo e($message->message); ?></td>
                            <td style="white-space:nowrap;"><?php echo e($message->created_at?->format('d M Y, h:i A')); ?></td>
                            <td>
                                <form method="POST" action="<?php echo e(route('admin.contact-messages.destroy', $message)); ?>"
                                    onsubmit="return confirm('Delete this message?')">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn btn-sm btn-outline-danger">
                                        <i class="bx bx-trash"></i> Delete
                                    </button>
                                </form>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="8" class="text-center text-muted py-4">
                                <?php echo e($search ? 'No messages match your search.' : 'No contact messages found.'); ?>

                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <?php if($messages->hasPages()): ?>
            <div class="mt-3">
                <?php echo e($messages->links()); ?>

            </div>
        <?php endif; ?>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Abdur Rahman\Desktop\faa\resources\views\backend\contact_messages\index.blade.php ENDPATH**/ ?>