

<?php $__env->startSection('content'); ?>
    
    <div class="row">
        <div class="col-12">
            <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-header pb-0">
              <div class="d-flex align-items-center">
                <p class="mb-0 font-weight-bolder">Edit Business Post</p>
                <label class="btn btn-<?php echo e($errors->first('iserror') == 'false' ? 'success' : 'primary'); ?> btn-sm ms-auto"><?php echo e($errors->first('response')); ?></label>
                
              </div>
            </div>
            <div class="card-body">
                <!--<img src="<?php echo e(asset('storage/images/test.jpg')); ?>">-->
                <form method="post" action="<?php echo e(route('business.update',$post->id)); ?>" id="addform" enctype="multipart/form-data" >
                    
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                    
                    <div class="row">
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="example-text-input" class="form-control-label">Name <b style="color:red"><?php echo e($errors->first('title')); ?></b></label>
                            <input class="form-control" name="title" type="text" placeholder="Happy diwali" value="<?php echo e($post->title); ?>">
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="example-text-input" class="form-control-label">Select Category <b style="color:red"><?php echo e($errors->first('category')); ?></b></label>
                            
                            <select class="fstdropdown-select form-control" id="category_id" name="category" required="required">
                                <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($c->id); ?>" <?php if($c->id == $post->category_id): ?> selected <?php endif; ?>><?php echo e($c->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                            
                          </div>
                        </div>
                        
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="example-text-input"  class="form-control-label">Select Sub Category</label>
                            
                            <select class="fstdropdown-select form-control" id="sub_category_id" name="subcategory">
                                <?php $__currentLoopData = $subcategories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($sc->id); ?>" <?php if($sc->id == $post->sub_category_id): ?> selected <?php endif; ?>><?php echo e($sc->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                            
                          </div>
                        </div>
                        
                         <div class="col-md-6">
                          <div class="form-group">
                            <label for="example-text-input" class="form-control-label">Select Language <b style="color:red"><?php echo e($errors->first('language')); ?></b></label>
                            
                            <select class="fstdropdown-select form-control" name="language" required="required">
                                <?php $__currentLoopData = $languages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($lan->language_code); ?>" <?php if($lan->language_code == $post->language): ?> selected <?php endif; ?>><?php echo e($lan->language_name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                            
                          </div>
                        </div>
                        
                        <?php if($post->json != ""): ?>
                            <div class="col-md-6" id="pick_zip_lay">
                            <div class="form-group">
                            <label for="example-text-input" class="form-control-label">Zip</label>
                                <input class="form-control" type="file" name="zip_file" accept=".zip">
                              </div>
                            </div>
                            
                            <div class="col-md-6">
                              <div class="form-group">
                                <label for="example-text-input" class="form-control-label">Thumbnail</b></label>
                                <input class="form-control" type="file" id="image_posts" name="thumbnail" accept=".jpg, .png, jpeg, .PNG, .JPG, .JPEG" onchange="fileValidation()">
                              </div>
                            </div>
                        
                        <?php else: ?>
                        
                            <div class="col-md-6">
                              <div class="form-group">
                                <label for="example-text-input" class="form-control-label">Post Image</b></label>
                                <input class="form-control" type="file" id="image_posts" name="image_posts" accept=".jpg, .png, jpeg, .PNG, .JPG, .JPEG" onchange="fileValidation()">
                              </div>
                            </div>
                        
                        <?php endif; ?>
                        
                       
                        <?php if($post->json == ""): ?>
                            
                        <?php endif; ?>
                        
                        <div class="col-md-12 card-body mt-n3">
                            <div class="row mb" id="previewImages">
                                <div class="imageCard col-xl-2 col-sm-3 mb-2">
                                  <div class="avatar avatar-xxl position-relative">
                                    <img src="<?php echo e(url($post->thumb_url)); ?>" id="imge" class="border-radius-md" alt="team-2">
                                    
                                  </div>
                                </div>
                            </div>
                        </div>
                        
                        
                        <div class="col-md-12" >
                          <div class="form-group">
   
                            <?php if(Session::get('admin_type') == "Demo"): ?>
                              <div class="btn btn-primary col-md-6 demo_action">Submit</div>
                              <?php else: ?>
                              <input class="btn btn-primary col-md-6" type="submit" value="Submit">
                              <?php endif; ?>
                            
                          </div>
                        </div>
                     
                    </div>
                </form>
            </div>
          </div>
        </div>
        
      </div>
        </div>
    </div>
<!--<p class='remove pull-right bg-danger' style='cursor:pointer;position: absolute;top: 0px;right: 15px;padding: 6px 10px;' id='"+i+"'><i class='fa fa-close'></i></p>-->
<script type="text/javascript">

    function fileValidation(){
        var fileInput = document.getElementById('image_posts');
        if (fileInput.files && fileInput.files[0]) {
            var reader = new FileReader();
            reader.onload = function(e) {
                document.getElementById("previewImages").innerHTML = "";
                $('#previewImages').append(
                "<div class='imageCard col-xl-2 col-sm-3 mb-2'>"+
                  "<div class='avatar avatar-xxl position-relative'>"+
                    "<img src='"+e.target.result+"' id='imge' class='border-radius-md' alt='team-2'>"+
                  "</div>"+
                "</div>");
            };
            reader.readAsDataURL(fileInput.files[0]);
        }
    }
    
    function imagePreview(fileInput) 
    { 
        if (fileInput.files && fileInput.files[0]) 
        {
            var fileReader = new FileReader();
            fileReader.onload = function (event) 
            {
                
                    
            };
            fileReader.readAsDataURL(fileInput.files[0]);
        }
    }
    
    $('#category_id').on('change', function () {
        var id = $(this).val();
        
        $.ajax({
            type: "GET",
            url: "/get-sub-category-by-id",
            data: {id : id},
            headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
            success: function(data) {
                $('#sub_category_id').empty();
                $("#sub_category_id").append('<option value="">Select Sub Category</option>');
                for (const val of data) {
                    try {
                        $('#sub_category_id').append('<option value='+val.id+'>'+val.name+'</option>');
                    } catch (e) {
                        console.log(e.message);
                    }
                   
                    
                }
                document.getElementById("sub_category_id").fstdropdown.rebind();
            },
        });
        
    });

</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /www/wwwroot/posterbanao.com/admin/resources/views/business/edit.blade.php ENDPATH**/ ?>