

<?php $__env->startSection('title', 'Properties'); ?>

<?php $__env->startSection('content'); ?>
<div class="content-wrapper">
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">Properties</h1>
                </div>
                <div class="col-sm-6">
                    <div class="float-sm-right">
                        <a href="<?php echo e(route('properties.create')); ?>" class="btn btn-primary">
                            <i class="fas fa-plus"></i> New Property
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <section class="content">
        <div class="container-fluid">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">All Properties</h3>
                </div>
                <div class="card-body">
                    <form action="<?php echo e(route('properties.index')); ?>" method="GET" class="mb-4">
                        <div class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="search" class="form-control" placeholder="Search by title or description..." value="<?php echo e(request('search')); ?>">
                                        <div class="input-group-append">
                                            <button type="submit" class="btn btn-primary">
                                                <i class="fas fa-search"></i>
                                            </button>
                                            <?php if(request('search')): ?>
                                                <a href="<?php echo e(route('properties.index', array_merge(request()->except('search'), ['search' => '']))); ?>" class="btn btn-danger">
                                                    <i class="fas fa-times"></i>
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <select name="type" class="form-control" onchange="this.form.submit()">
                                        <option value="">All Types</option>
                                        <?php $__currentLoopData = $types; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($key); ?>" <?php echo e(request('type') == $key ? 'selected' : ''); ?>>
                                                <?php echo e($name); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <select name="status" class="form-control" onchange="this.form.submit()">
                                        <option value="">All Status</option>
                                        <option value="active" <?php echo e(request('status') == 'active' ? 'selected' : ''); ?>>Active</option>
                                        <option value="inactive" <?php echo e(request('status') == 'inactive' ? 'selected' : ''); ?>>Inactive</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <select name="display_status" class="form-control" onchange="this.form.submit()">
                                        <option value="">All Display</option>
                                        <option value="mobile" <?php echo e(request('display_status') == 'mobile' ? 'selected' : ''); ?>>Mobile Display</option>
                                        <option value="homepage" <?php echo e(request('display_status') == 'homepage' ? 'selected' : ''); ?>>Homepage Display</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </form>

                    <div class="table-responsive">
                        <table class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Image</th>
                                    <th>Title</th>
                                    <th>Type</th>
                                    <th>Details</th>
                                    <th>Status</th>
                                    <th>Display</th>
                                    <th>Sort Order</th>
                                    <th>Created</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $properties; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $property): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td><?php echo e($property->id); ?></td>
                                        <td>
                                            <img src="<?php echo e($property->card_image_url); ?>" 
                                                 alt="<?php echo e($property->title); ?>" 
                                                 class="img-thumbnail" 
                                                 style="width: 60px; height: 60px; object-fit: cover;">
                                        </td>
                                        <td>
                                            <div>
                                                <strong><?php echo e($property->title); ?></strong>
                                                <br>
                                                <small class="text-muted"><?php echo e(Str::limit($property->short_description, 50)); ?></small>
                                            </div>
                                        </td>
                                        <td>
                                            <span class="badge bg-info text-white"><?php echo e($property->type_name); ?></span>
                                        </td>
                                        <td>
                                            <div class="text-sm">
                                                <div><i class="fas fa-bed"></i> <?php echo e($property->bedrooms); ?> Bedrooms</div>
                                                <div><i class="fas fa-bath"></i> <?php echo e($property->bathrooms); ?> Bathrooms</div>
                                                <div><i class="fas fa-ruler-combined"></i> <?php echo e($property->formatted_area); ?></div>
                                            </div>
                                        </td>
                                        <td>
                                            <?php
                                                $statusColors = [
                                                    'active' => ['bg' => 'bg-success', 'text' => 'text-white'],
                                                    'inactive' => ['bg' => 'bg-danger', 'text' => 'text-white']
                                                ];
                                                $status = $property->is_active ? 'active' : 'inactive';
                                                $colors = $statusColors[$status];
                                            ?>
                                            <span class="badge <?php echo e($colors['bg']); ?> <?php echo e($colors['text']); ?> p-2">
                                                <?php echo e(ucfirst($status)); ?>

                                            </span>
                                        </td>
                                        <td>
                                            <div class="d-flex flex-column gap-1">
                                                <span class="badge <?php echo e($property->getDisplayStatusBadgeClass()); ?> p-1">
                                                    <i class="fas fa-mobile-alt"></i> Mobile
                                                </span>
                                                <span class="badge <?php echo e($property->getHomepageDisplayBadgeClass()); ?> p-1">
                                                    <i class="fas fa-home"></i> Homepage
                                                </span>
                                            </div>
                                        </td>
                                        <td>
                                            <span class="badge bg-secondary"><?php echo e($property->sort_order); ?></span>
                                        </td>
                                        <td><?php echo e($property->created_at->format('M d, Y H:i')); ?></td>
                                        <td>
                                            <div class="btn-group" role="group">
                                                <a href="<?php echo e(route('properties.show', $property)); ?>" class="btn btn-sm btn-info" title="View Details">
                                                    <i class="fas fa-eye"></i>
                                                </a>
                                                <a href="<?php echo e(route('properties.edit', $property)); ?>" class="btn btn-sm btn-primary" title="Edit">
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                                <form method="POST" action="<?php echo e(route('properties.toggle-active', $property)); ?>" class="d-inline">
                                                    <?php echo csrf_field(); ?>
                                                    <button type="submit" class="btn btn-sm <?php echo e($property->is_active ? 'btn-warning' : 'btn-success'); ?>" title="<?php echo e($property->is_active ? 'Deactivate' : 'Activate'); ?>">
                                                        <i class="fas <?php echo e($property->is_active ? 'fa-eye-slash' : 'fa-eye'); ?>"></i>
                                                    </button>
                                                </form>
                                                <form method="POST" action="<?php echo e(route('properties.toggle-mobile-display', $property)); ?>" class="d-inline">
                                                    <?php echo csrf_field(); ?>
                                                    <button type="submit" class="btn btn-sm <?php echo e($property->display_on_mobile ? 'btn-warning' : 'btn-success'); ?>" title="<?php echo e($property->display_on_mobile ? 'Hide from Mobile' : 'Show on Mobile'); ?>">
                                                        <i class="fas fa-mobile-alt"></i>
                                                    </button>
                                                </form>
                                                <form method="POST" action="<?php echo e(route('properties.toggle-homepage-display', $property)); ?>" class="d-inline">
                                                    <?php echo csrf_field(); ?>
                                                    <button type="submit" class="btn btn-sm <?php echo e($property->display_on_homepage ? 'btn-warning' : 'btn-success'); ?>" title="<?php echo e($property->display_on_homepage ? 'Hide from Homepage' : 'Show on Homepage'); ?>">
                                                        <i class="fas fa-home"></i>
                                                    </button>
                                                </form>
                                                <form method="POST" action="<?php echo e(route('properties.destroy', $property)); ?>" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this property?')">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('DELETE'); ?>
                                                    <button type="submit" class="btn btn-sm btn-danger" title="Delete">
                                                        <i class="fas fa-trash"></i>
                                                    </button>
                                                </form>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="10" class="text-center">No properties found</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="card-footer">
                    <?php echo e($properties->appends(request()->query())->links()); ?>

                </div>
            </div>
        </div>
    </section>
</div>

<style>
.badge {
    font-size: 0.8em;
    font-weight: 500;
    padding: 0.4em 0.8em;
}
.badge.bg-success {
    background-color: #28a745 !important;
}
.badge.bg-danger {
    background-color: #dc3545 !important;
}
.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #212529 !important;
}
.badge.bg-info {
    background-color: #17a2b8 !important;
}
.badge.bg-secondary {
    background-color: #6c757d !important;
}
.btn-group .btn {
    margin-right: 2px;
}
.btn-group .btn:last-child {
    margin-right: 0;
}
.gap-1 {
    gap: 0.25rem;
}
.d-flex.flex-column {
    flex-direction: column;
}
</style>
<?php $__env->stopSection(); ?> 
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\solen-north-coast\resources\views/properties/index.blade.php ENDPATH**/ ?>