Current File : //home/tradevaly/public_html/resources/views/user/pages/addoffer.blade.php
@extends('user.ayaan.master')

@push('style')
 <link href="{{ asset('/assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />

@endpush

@section('content')
<div class="container-fluid">
  <div class="row">
    <div class="col-md-8 mb-4">
      <div class="card">
        <div class="card-header card-header-icon card-header-info">
          <h4 class="card-title">ADD NEW Buy Offer
          </h4>
        </div>
        <div class="card-body">
          <form action="{{url('user/offer/add')}}" method="POST" enctype="multipart/form-data">
              @csrf
            <div class="row">
              <div class="col-md-8 mb-4">
                  <div class="form-group">
                  <label class="bmd-label-floating">Product Name </label>
                  <input type="text" name="title" class="form-control" required>
                </div>
              </div>
              <div class="col-md-8 mb-4">
                <div class="form-group">
                  <label class="bmd-label-floating">Category </label>
                  <select class="form-control select2" name="category_id">
                    <option disabled selected>Select Category</option>
                    @foreach ($caegories as $category)
                    <option value="{{$category->id}}">{{$category->name}}</option>
                    @endforeach
                  </select>
                </div>
               </div>
               
               <div class="col-md-8 mb-4">
                    <div class="form-group">
                        <label class="bmd-label-floating">Select Subcategory</label>
                        <select class="form-control select2" name="sub_id" required>
                         <option value="">Select Sub Category</option>
                         </select>
                     </div>
                </div>
            
             <div class="col-md-8 mb-4">
                <div class="form-group">
                    <label class="bmd-label-floating">Select Child Category</label>
                    <select class="form-control select2" name="child_id">
                        <option value="">Select Child Category</option>
                    </select>
                  </div>
            </div>
            
            
              <div class="col-md-8 mb-4">
                <div class="form-group">
                  <label class="bmd-label-floating mt-3">Tags </label>
                  <select class="form-control" name="tags[]" id="example" multiple>
                    <option disabled selected>Select Tags</option>
                     @foreach ($tags as $category)
                        <option value="{{$category->name}}">{{$category->name}}</option>
                    @endforeach
                  </select>
                </div>
               </div>
              <div class="col-md-12 mb-4">
                  <div class="form-group">
                  <label class="bmd-label-floating mt-3">Description </label>
                  <textarea  id="elm1" name="des" aria-hidden="true"></textarea>
                </div>
              </div>
            </div>
            <button type="submit" class="btn btn-info pull-right">Upload</button>
            <div class="clearfix"></div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
@stop

@section('script')
<script src="{{ asset('/assets/libs/select2/select2.min.js') }}"></script>

    <!-- dropzone plugin -->
    <script src="{{ asset('/assets/libs/dropzone/dropzone.min.js') }}"></script>
    <script src="{{ asset('assets/libs/tinymce/tinymce.min.js') }}"></script>
    <!-- init js -->
    <script src="{{ asset('/assets/js/pages/ecommerce-select2.init.js') }}"></script>
    <script src="{{ asset('assets/js/pages/form-editor.init.js') }}"></script>
<script>
$(function() {
$('#example').select2({
         multiple: true,
         maximumSelectionSize: 1
    });
});
</script>
<script>
$(document).ready(function() {
      $(".btn-success").click(function(){ 
          var lsthmtl = $(".clone").html();
          $(".increment").after(lsthmtl);
      });
       $("body").on("click",".btn-danger",function(){ 
          $(this).parents("#cloning").remove();
      });
    });
    
    
    
    
    
    
    $(document).on('change', '[name=category_id]', function() {
            var child_id = $(this).val();
            get_cat(child_id);
        });
        
        
        function get_cat(child_id) {
            $('[name="sub_id"]').html("");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url: "{{ route('ajax.cat')}}",
                type: 'POST',
                data: {
                    sub_id  : child_id
                },
                success: function (response) {
                    $(".select2").select2();
                    var obj = JSON.parse(response);
                    if(obj != '') {
                        $('[name="sub_id"]').html(obj);
                    }
                }
            });
        }
        
        
        
        
        
        
        
        $(document).on('change', '[name=sub_id]', function() {
            var child_id = $(this).val();
            get_child(child_id);
        });
        
        
        function get_child(child_id) {
            $('[name="child_id"]').html("");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url: "{{ route('ajax.subcat')}}",
                type: 'POST',
                data: {
                    sub_id  : child_id
                },
                success: function (response) {
                    $(".select2").select2();
                    var obj = JSON.parse(response);
                    if(obj != '') {
                        $('[name="child_id"]').html(obj);
                    }
                }
            });
        }
        
        
        
        
</script>
@endsection