<?php
    $navbar = 'nav-main-theme';
?>

<?php $__env->startSection('title', 'العقارات'); ?>
<?php $__env->startSection('css'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('assets/css/pages/products/show.css')); ?>">
    <style>
        .bootstrap-select {
            width: 100% !important;
        }

        .bootstrap-select .dropdown-menu {
            max-height: 400px !important;
        }
    </style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>


    <section id="search" class="mb-5">
        <div class="container">
            <h2 class="section-title line-after mb-4 mt-4">بحث متقدم</h2>
            <div style="padding-top: 33px !important;" class="box px-4 mb-2">
                <form action="<?php echo e(url('products')); ?>" method="get">
                    <div class="row">

                        <div class="col-md-3">
                            <?php if (isset($component)) { $__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a = $component; } ?>
<?php $component = App\View\Components\FormGroup::resolve(['properties' => [
                                'select' => [
                                    'name' => 'region',
                                    'list' => $regions,
                                    'selected' => $qRegion,
                                    'options' => [
                                        'data-live-search' => true,
                                        'class' => 'font-17 searchable-select',
                                        'placeholder' => 'اختر الحي',
                                    ],
                                ],
                            ]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('form-group'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\FormGroup::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a)): ?>
<?php $component = $__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a; ?>
<?php unset($__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a); ?>
<?php endif; ?>
                        </div>

                        <div class="col-md-3">
                            <?php if (isset($component)) { $__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a = $component; } ?>
<?php $component = App\View\Components\FormGroup::resolve(['properties' => [
                                'select' => [
                                    'name' => 'rooms',
                                    'list' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                                    'selected' => $qRoom,
                                    'options' => ['class' => 'font-17', 'placeholder' => 'عدد الغرف'],
                                ],
                            ]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('form-group'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\FormGroup::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a)): ?>
<?php $component = $__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a; ?>
<?php unset($__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a); ?>
<?php endif; ?>
                        </div>


                        <div class="col-md-3">
                            <?php if (isset($component)) { $__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a = $component; } ?>
<?php $component = App\View\Components\FormGroup::resolve(['properties' => [
                                'select' => [
                                    'name' => 'type',
                                    'list' => $buildingTypes,
                                    'selected' => $qType,
                                    'text' => 'type',
                                    'options' => [
                                        'class' => 'font-17',
                                        'placeholder' => 'اختر النوع',
                                        'data-url-get-neighborhoods' => route('getNeighborhoods'),
                                    ],
                                ],
                            ]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('form-group'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\FormGroup::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a)): ?>
<?php $component = $__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a; ?>
<?php unset($__componentOriginal1c669f5858ba8e548f3c58b275327fb2f8e6401a); ?>
<?php endif; ?>
                        </div>




                        <div class="col-md-3">
                            <button type="submit" class="btn btn-main btn-block">بحث</button>
                        </div>

                    </div>
                </form>
            </div>

            <?php if($search == true): ?>
                <a href="<?php echo e(url('products')); ?>" class="text-danger">
                    <svg fill="#dc3545" width="15px" height="15px" xmlns="http://www.w3.org/2000/svg"
                        viewBox="0 0 512 512">
                        <path
                            d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c-9.4 9.4-9.4 24.6 0 33.9l47 47-47 47c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l47-47 47 47c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-47-47 47-47c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-47 47-47-47c-9.4-9.4-24.6-9.4-33.9 0z" />
                    </svg>
                    حذف قيم البحث
                </a>
            <?php endif; ?>

        </div>
    </section>

    <header class="mt-5 mt-lg-0">
        <div class="container">
            <h1 class="line-after font-30">عقاراتنا</h1>
        </div>
    </header>

    <main class="mt-3 mb-5 pb-5">
        <div class="container">
            <div class="row mt-5">
                <?php if($search == true && count($rows) == 0): ?>
                    <div class="col-12">
                        <div class="box text-center py-4">
                            لم يتم العثور علي نتائج لبحثك !
                            <a href="<?php echo e(url('products')); ?>">الرجوع لجميع منتجاتنا</a>
                        </div>
                    </div>
                <?php else: ?>
                    <?php $__currentLoopData = $rows; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prod): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="col-lg-4 col-md-6 mb-4">
                            <div class="product-box h-100">

                                <div class="main-image">

                                    <a href="<?php echo e(url('product/' . Str::slug($prod->name)) . '-' . $prod->id); ?>">
                                        <img class="" src="<?php echo e(mediumAsset('products/' . $prod->main_image)); ?>"
                                            alt="">
                                    </a>

                                    <?php if($prod->get_deal_type != null): ?>
                                        <span class="badge-deal-type"><?php echo e($prod->get_deal_type->type); ?></span>
                                    <?php endif; ?>

                                    <?php
                                        if ($prod->get_status->id == 1) {
                                            $badgeStatusColor = 'success';
                                        } elseif ($prod->get_status->id == 2) {
                                            $badgeStatusColor = 'danger';
                                        } elseif ($prod->get_status->id == 3) {
                                            $badgeStatusColor = 'blue';
                                        } else {
                                            $badgeStatusColor = 'dark';
                                        }
                                    ?>

                                    <?php if($prod->get_status != null): ?>
                                        <span
                                            class="badge-status <?php echo e($badgeStatusColor); ?>"><?php echo e($prod->get_status->status); ?></span>
                                    <?php endif; ?>

                                    <span data-price="<?php echo e(number_format($prod->price, 0, '.', ',')); ?> ريال سعودي"
                                        class="price set-price">
                                    </span>
                                </div>

                                <a href="<?php echo e(url('product/' . Str::slug($prod->name)) . '-' . $prod->id); ?>">

                                    <div class="info">
                                        <h3><?php echo e($prod->name); ?></h3>
                                        <?php if($prod->get_developer != null): ?>
                                            <div class="dev">
                                                <img class="dev-icon" src="<?php echo e(asset('assets/images/products/dev.svg')); ?>"
                                                    alt="">
                                                المطور : <?php echo e(Str::limit($prod->get_developer->name, 100)); ?>

                                            </div>
                                        <?php endif; ?>
                                        <img class="d-inline-block" style="width:9px"
                                            src="<?php echo e(asset('assets/images/products/city.svg')); ?>" alt="">
                                        <?php if($prod->get_city != null): ?>
                                            <span class="mr-1 ml-3"><?php echo e($prod->get_city->name); ?></span>
                                        <?php endif; ?>
                                        <img class="d-inline-block" style="width:18px"
                                            src="<?php echo e(asset('assets/images/products/region.svg')); ?>" alt="">
                                        <?php if($prod->get_region != null): ?>
                                            <span class="mr-1"><?php echo e($prod->get_region->name); ?></span>
                                        <?php endif; ?>
                                    </div>

                                    <div class="details">
                                        <div class="row">
                                            <div class="col text-center">
                                                <div class="icon">
                                                    <span class="count"><?php echo e($prod->room_numbers); ?></span>
                                                    <img class="d-inline-block" style="width:26px"
                                                        src="<?php echo e(asset('assets/images/products/room.svg')); ?>"
                                                        alt="">
                                                </div>
                                                <span class="mr-1">غرفة نوم</span>
                                            </div>

                                            <div class="col text-center middel-col">
                                                <div class="icon">
                                                    <span class="count"><?php echo e($prod->bathrooms_numbers); ?></span>
                                                    <img class="d-inline-block" style="width:26px"
                                                        src="<?php echo e(asset('assets/images/products/bathroom.svg')); ?>"
                                                        alt="">
                                                </div>
                                                <span class="mr-1">حمام</span>
                                            </div>

                                            <div class="col text-center">
                                                <div class="icon">
                                                    <span class="count"><?php echo e($prod->area_in_metres); ?></span>
                                                    <img class="d-inline-block" style="width:26px"
                                                        src="<?php echo e(asset('assets/images/products/mtr.svg')); ?>" alt="">
                                                </div>
                                                <span class="mr-1">مساحة</span>
                                            </div>

                                        </div>
                                    </div>

                                </a>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                    <div class="col-12 ">
                        <div class="pagination d-flex justify-content-center">
                            <div class="nav-links">
                                <!-- زر السابق -->
                                <?php if($rows->onFirstPage()): ?>
                                    <span class="page-numbers prev disabled">&laquo;</span>
                                <?php else: ?>
                                    <a class="page-numbers prev" title="السابق" href="<?php echo e($rows->previousPageUrl()); ?>">&laquo;</a>
                                <?php endif; ?>

                                <!-- أول صفحة دائمًا -->
                                <a class="page-numbers <?php echo e($rows->currentPage() == 1 ? 'current' : ''); ?>"
                                    href="<?php echo e($rows->url(1)); ?>">1</a>

                                <!-- النقاط إذا كانت الصفحة الحالية أكبر من 3 -->
                                <?php if($rows->currentPage() > 3): ?>
                                    <span class="page-numbers dots">...</span>
                                <?php endif; ?>

                                <!-- أرقام الصفحات حول الصفحة الحالية -->
                                <?php for($i = max(2, $rows->currentPage() - 1); $i <= min($rows->lastPage() - 1, $rows->currentPage() + 1); $i++): ?>
                                    <a class="page-numbers <?php echo e($i == $rows->currentPage() ? 'current' : ''); ?>"
                                        href="<?php echo e($rows->url($i)); ?>"><?php echo e($i); ?></a>
                                <?php endfor; ?>

                                <!-- النقاط إذا كانت الصفحة الحالية أصغر من آخر صفحتين -->
                                <?php if($rows->currentPage() < $rows->lastPage() - 2): ?>
                                    <span class="page-numbers dots">...</span>
                                <?php endif; ?>

                                <!-- آخر صفحة دائمًا -->
                                <?php if($rows->lastPage() > 1): ?>
                                    <a class="page-numbers <?php echo e($rows->currentPage() == $rows->lastPage() ? 'current' : ''); ?>"
                                        href="<?php echo e($rows->url($rows->lastPage())); ?>"><?php echo e($rows->lastPage()); ?></a>
                                <?php endif; ?>

                                <!-- زر التالي -->
                                <?php if($rows->hasMorePages()): ?>
                                    <a class="page-numbers next" href="<?php echo e($rows->nextPageUrl()); ?>" title="التالي">&raquo;</a>
                                <?php else: ?>
                                    <span class="page-numbers next disabled">&raquo;</span>
                                <?php endif; ?>
                            </div>
                        </div>



                    </div>
                <?php endif; ?>
            </div>
        </div>
    </main>



<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <script>
        $(document).ready(function() {

            $('.searchable-select').selectpicker();
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('main.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\wjhatna\resources\views/main/products/index.blade.php ENDPATH**/ ?>