<?php echo $__env->make('admin::layouts.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php
use App\Models\Categories;
use App\Models\Supliers;
use App\Models\Brands;
?>
<main id="main-container">
        <!-- Hero -->
        <div class="bg-body-light">
          <div class="content content-full">
            <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
              <h1 class="flex-grow-1 fs-3 fw-semibold my-2 my-sm-3">Edit Service</h1>
              <nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item">Dashboard</li>
                  <li class="breadcrumb-item">Service</li>
                  <li class="breadcrumb-item active" aria-current="page">Edit Service</li>
                </ol>
              </nav>
            </div>
          </div>
        </div>
        <!-- END Hero -->

        <!-- Page Content -->
        <div class="content">
          <!-- Your Block -->
          <div class="block block-rounded">
            <div class="block-header block-header-default">
              <h3 class="block-title">Edit Service</h3>
            </div>
            <div class="block-content">
            <?php if(Session::has('success')): ?> <div class="alert alert-success mt-2 mb-2"><?php echo e(Session::get('success')); ?></div><?php endif; ?>
            <?php if(Session::has('fail')): ?> <div class="alert alert-danger mt-2 mb-2"><?php echo e(Session::get('fail')); ?></div><?php endif; ?>
            <form class="row" action="" method="POST" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Service ID</label>
                      <input type="text" class="form-control" name="service_id" value="<?php echo e($service_details->service_id); ?>" readonly required>
                      <?php if($errors->has("service_id")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('service_id')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Name</label>
                      <input type="text" class="form-control" name="name" value="<?php echo e($service_details->name); ?>" required>
                      <?php if($errors->has("name")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('name')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Code</label>
                      <input type="text" class="form-control" name="code" value="<?php echo e($service_details->code); ?>" required>
                      <?php if($errors->has("code")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('code')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Price</label>
                      <input type="number" class="form-control" name="price" value="<?php echo e($service_details->price); ?>" required>
                      <?php if($errors->has("price")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('price')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Parent Category</label>
                      <select class="js-select2 form-select" id="parent_category" name="parent_category" style="width: 100%;" data-placeholder="Select a category..">
                        <?php if($service_details->parent_category) { ?> 
                            <option value="<?php echo e($service_details->parent_category); ?>"><?php echo e(Categories::where('id', $service_details->parent_category)->value('category_name')); ?></option>
                        <?php } ?>
                        <option></option>
                      <?php foreach($parent_categories as $parent_category){ ?> 
                        <option value="<?php echo e($parent_category->id); ?>"><?php echo e($parent_category->category_name); ?></option>
                        <?php } ?>
                      </select>
                      <?php if($errors->has("parent_category")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('parent_category')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                    <label class="form-label">Sub Category</label>
                    <select class="js-select2 form-select" id="sub_category" name="sub_category" style="width: 100%;" data-placeholder="Select a parent category..">
                    <?php if($service_details->sub_category) { ?> 
                        <option value="<?php echo e($service_details->sub_category); ?>"><?php echo e(Categories::where('id', $service_details->sub_category)->value('category_name')); ?></option>
                    <?php } ?>
                    <option></option>
                    </select>
                      <?php if($errors->has("sub_category")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('sub_category')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Featured Image</label>
                      <input type="file" class="form-control" name="featured_image" >
                      <?php if($errors->has("featured_image")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('featured_image')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-12 mb-3">
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" id="example-checkbox-default1" name="price_variant" <?php echo e($service_details->price_variant == 'on' ? 'checked' : ''); ?>>
                        <label class="form-check-label" for="example-checkbox-default1">Price Variant</label>
                    </div>
                    </div>
            <div>        
            
                      <button type="submit" class="btn btn-success mt-4">Save</button>
                    </div>
                  </form>
            </div>
          </div>
          <!-- END Your Block -->
        </div>
        <!-- END Page Content -->
</main>
<!-- END Main Container -->
<?php echo $__env->make('admin::layouts.footer', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<script>
    $(document).ready(function() {
        $('#parent_category').change(function() {
            var parentId = $(this).val();
            $('#sub_category').empty();
            if (parentId) {
                $.ajax({
                    url: '<?php echo e(url('admin/get-sub-categories')); ?>/' + parentId,
                    type: 'GET',
                    dataType: 'json',
                    success: function(data) {
                        $.each(data, function(key, value) {
                            $('#sub_category').append('<option value="'+ value.id +'">'+ value.category_name +'</option>');
                        });
                    }
                });
            } else {
                $('#sub_category').append('<option value="">Select a sub category..</option>');
            }
        });
    });
</script>







<?php /**PATH /home/u446954234/domains/orionerp.xyz/public_html/indianheavenrestaurant/Modules/Admin/resources/views/service/edit_service.blade.php ENDPATH**/ ?>