<?php $__env->startSection('content'); ?>
    <section class="section">

        <div class="card col-6 m-auto">
            <div class="card-header">
                <h4 class="card-title text-center">    <img style="    width: 15%;" src="/site/assets/images/Group_542.svg" alt=""></h4>
            </div>
            <div class="card-content">
                <div class="card-body">
                    <?php if(!isset($form)): ?>
                        <form class="form form-vertical" method="post" action="<?php echo e(route('site.has-homes.store')); ?>"><?php echo csrf_field(); ?>
                    <?php endif; ?>
                        <div class="form-body">
                            <div class="row px-3">
                                <div class="col-12">
                                    <h4>Evimi Açabilirim - Başvuru Formu</h4>
                                    <hr>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Ad Soyad" name="name" <?php if(isset($form)): ?> value="<?php echo e($form->name); ?>" disabled <?php endif; ?> required id="first-name-icon">
                                            <div class="form-control-icon">
                                                <i class="bi bi-person"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">

                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Telefon Numarası" name="telephone" <?php if(isset($form)): ?> value="<?php echo e($form->telephone); ?>" disabled <?php endif; ?> required id="email-id-icon">
                                            <div class="form-control-icon">
                                                <i class="bi bi-telephone"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <select type="text" class="form-control" name="city_id" <?php if(isset($form)): ?> disabled <?php endif; ?> id="email-id-icon">
                                                <?php $__currentLoopData = \App\Models\City::all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option <?php if(isset($form) && $form->city_id == $city->id): ?> selected <?php endif; ?> value="<?php echo e($city->il_id); ?>"><?php echo e($city->il_adi); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <?php if(isset($form)): ?>
                                                <select class="form-control" disabled>
                                                    <option value="0"><?php echo e(\App\Models\Town::where('ilce_id',$form->town_id)->first()->ilce_adi); ?></option>
                                                </select>
                                            <?php else: ?>
                                                <select class="form-control" name="town_id">
                                                    <option value="0">İlçe</option>
                                                </select>
                                            <?php endif; ?>
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <?php if(isset($form)): ?>
                                                <select class="form-control" disabled>
                                                    <option value="0"><?php echo e(\App\Models\District::where('mahalle_id',$form->district_id)->first()->mahalle_adi); ?></option>
                                                </select>
                                            <?php else: ?>
                                                <select class="form-control" name="district_id">
                                                    <option value="0">Mahalle</option>
                                                </select>
                                            <?php endif; ?>
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <?php if(isset($form)): ?>
                                                <select class="form-control" disabled>
                                                    <option value="0"><?php echo e(\App\Models\Street::where('sokak_id',$form->street_id)->first()->sokak_adi); ?></option>
                                                </select>
                                            <?php else: ?>
                                                <select class="form-control" name="street_id">
                                                    <option value="0">Sokak</option>
                                                </select>
                                            <?php endif; ?>
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Bina No" name="apartment_no" <?php if(isset($form)): ?> value="<?php echo e($form->apartment_no); ?>" disabled <?php endif; ?> required id="email-id-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Kat" name="floor" <?php if(isset($form)): ?> value="<?php echo e($form->floor); ?>" disabled <?php endif; ?> required id="email-id-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="text" class="form-control" placeholder="Daire" name="apartment" <?php if(isset($form)): ?> value="<?php echo e($form->apartment); ?>" disabled <?php endif; ?> required id="email-id-icon" />
                                            <div class="form-control-icon">
                                                <i class="bi bi-geo-alt"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-12 my-3">
                                    <hr>
                                </div>
                                <div class="col-12">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="number" min="1" class="form-control" placeholder="Ağırlayabileceğim Kişi Sayısı" name="person_count" <?php if(isset($form)): ?> value="<?php echo e($form->apartment); ?>" disabled <?php endif; ?> required id="email-id-icon">

                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="date" min="<?php echo e(now()->format('Y-m-d')); ?>" class="form-control" placeholder="Başlangıç Tarihi" name="start_date" <?php if(isset($form)): ?> value="<?php echo e($form->start_date); ?>" disabled <?php endif; ?> id="first-name-icon">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="date" min="<?php echo e(now()->format('Y-m-d')); ?>" class="form-control" placeholder="Bitiş Tarihi" name="end_date" <?php if(isset($form)): ?> value="<?php echo e($form->end_date); ?>" disabled <?php endif; ?> id="first-name-icon">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-12">

                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                           <textarea style="min-height: 20vh;    resize: none;" type="text" class="form-control" placeholder="Ulaşım Yöntemleri:" name="car_types" <?php if(isset($form)): ?> disabled <?php endif; ?> id="email-id-icon"><?php if(isset($form)): ?> <?php echo e($form->car_types); ?> <?php endif; ?></textarea>

                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="number" min="1" class="form-control" placeholder="Oda Sayısı" name="room_count" <?php if(isset($form)): ?> value="<?php echo e($form->room_count); ?>" disabled <?php endif; ?> required id="first-name-icon">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-6">

                                    <div class="form-group has-icon-right">
                                        <div class="position-relative">
                                            <input type="number" min="0" name="meter" required class="form-control" placeholder="Metrekare" id="email-id-icon">
                                        </div>
                                    </div>
                                </div>
                                <?php if(!isset($form)): ?>
                                <div class="col-12 d-flex justify-content-end mt-3">
                                    <button type="submit" class="btn btn-secondary me-1 mb-1 px-5" style="border-radius: 15px;">Başvur</button>
                                </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    <?php if(!isset($form)): ?>
                        </form>
                    <?php endif; ?>
                </div>
            </div>
        </div>

    </section>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('js'); ?>
    <script>
        $('select[name="city_id"]').on('change',function (){
            $.ajax({
                url: "<?php echo e(route('getTownsFromCity')); ?>",
                type: "post",
                data: {'_token':'<?php echo e(csrf_token()); ?>','city_id':$('select[name="city_id"]').val()} ,
                success: function (response) {
                    $('select[name="town_id"]').empty().append('<option value="0">İlçe</option>');
                    $('select[name="district_id"]').empty().append('<option value="0">Mahalle</option>');
                    $('select[name="street_id"]').empty().append('<option value="0">Sokak</option>');
                    $.each(response.towns,function (index,item){
                        $('select[name="town_id"]').append('<option value="'+item.ilce_id+'">'+item.ilce_adi+'</option>');
                    })
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    console.log(textStatus, errorThrown);
                }
            });
        })

        $('select[name="town_id"]').on('change',function (){
            $.ajax({
                url: "<?php echo e(route('getDistrictsFromTown')); ?>",
                type: "post",
                data: {'_token':'<?php echo e(csrf_token()); ?>','town_id':$('select[name="town_id"]').val()} ,
                success: function (response) {
                    $('select[name="district_id"]').empty().append('<option value="0">Mahalle</option>');
                    $('select[name="street_id"]').empty().append('<option value="0">Sokak</option>');
                    $.each(response.districts,function (index,item){
                        $('select[name="district_id"]').append('<option value="'+item.mahalle_id+'">'+item.mahalle_adi+'</option>');
                    })
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    console.log(textStatus, errorThrown);
                }
            });
        })

        $('select[name="district_id"]').on('change',function (){
            $.ajax({
                url: "<?php echo e(route('getStreetsFromDistrict')); ?>",
                type: "post",
                data: {'_token':'<?php echo e(csrf_token()); ?>','district_id':$('select[name="district_id"]').val()} ,
                success: function (response) {
                    $('select[name="street_id"]').empty().append('<option value="0">Sokak</option>');
                    $.each(response.streets,function (index,item){
                        $('select[name="street_id"]').append('<option value="'+item.sokak_id+'">'+item.sokak_adi+'</option>');
                    })
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    console.log(textStatus, errorThrown);
                }
            });
        })
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('site.pages.build', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\kardesyuvan\resources\views/site/pages/evimi_acabilirim.blade.php ENDPATH**/ ?>