@extends('template.app') @section('meta') @endsection @section('title') Dealer Edit @endsection @section('styles')
<link href="{{ asset('assets/css/dropify.min.css') }}" rel="stylesheet">
<link href="{{ asset('assets/css/sweetalert2.bundle.css') }}" rel="stylesheet"> @endsection @section('content') <div class="page-breadcrumb">
  <div class="row">
    <div class="col-7 align-self-center">
      <h4 class="page-title text-truncate text-dark font-weight-medium mb-1">Dealer Master</h4>
      <div class="d-flex align-items-center">
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb m-0 p-0">
            <li class="breadcrumb-item">
              <a href="{{ route('dashboard') }}" class="text-muted">Dashboard</a>
            </li>
            <li class="breadcrumb-item">
              <a href="{{ route('dealer') }}" class="text-muted">Dealer Master</a>
            </li>
            <li class="breadcrumb-item text-muted active" aria-current="page">Edit</li>
          </ol>
        </nav>
      </div>
    </div>
  </div>
</div>
<div class="container-fluid">
  <div class="row">
    <div class="col-12">
      <div class="card">
        <div class="card-body">
          <form action="{{ route('dealer.update') }}" name="form" id="form" method="post" enctype="multipart/form-data"> 
          @csrf 
          @method('PATCH')
            <input type="hidden" name="id" value="{{ $data->id }}">
          <div class="row">
              <div class="form-group col-sm-3">
                <label for="name">Dealer Name :-</label>
                <input type="text" name="dealer_name" value="{{ $data->dealer_name }}" id="name" class="form-control" placeholder="Enter Dealer Name">
                <span class="kt-form__help error name"></span>
              </div>
              <div class="form-group col-sm-3">
                <label for="years">Dealer Email :-</label>
                <input type="email"  value="{{ $data->dealer_email }}" name="dealer_email" id="dealer_email" class="form-control" placeholder="Enter Dealer Email">
                <span class="kt-form__help error years"></span>
              </div>
              <div class="form-group col-sm-3">
                <label for="amount">Dealer Phone Number :-</label>
                <input type="number"  value="{{ $data->dealer_mobile_no }}" name="dealer_mobile_no" class="form-control" placeholder="Enter Phone Number">
                <span class="kt-form__help error amount"></span>
              </div>
              <div class="form-group col-sm-3">
                <label for="profit">Dealer Address :-</label>
                <textarea  name="dealer_address"  class="form-control" placeholder="Enter Address">{{ $data->dealer_address }}</textarea>
                <span class="kt-form__help error profit"></span>
              </div>
              <div class="form-group col-sm-3">
                <label for="gst_percentage">State :-</label>
                <!--<input type="text"  value="{{ $data->state }}" name="state" id="state" class="form-control" placeholder="Enter State">-->
                <select name="state" id="state" class="form-control" style="text-transform:uppercase">
                    <option value="">Select State</option>
                    @if(isset($states)) 
                        @foreach($states as $state)
                             <option value="{{ $state->id }}" @if($data->state == $state->id) selected @endif> {{ $state->name }}</option>
                        @endforeach
                     @endif
                </select>         
                <span class="kt-form__help error gst_percentage"></span>
              </div>
              <div class="form-group col-sm-3">
                <label for="city">City :-</label>
                <input type="text"  value="{{ $data->city }}" name="city" class="form-control" placeholder="City">
                <span class="kt-form__help error city"></span>
              </div>
              <div class="form-group col-sm-3">
                <label for="gst">GST (%) :-</label>
                <input type="text"  value="{{ $data->gst }}" name="gst" id="gst" class="form-control">
                <span class="kt-form__help error gst"></span>
              </div>
              <div class="form-group col-sm-3">
                <label for="gst_no">GST No:-</label>
                <input type="text"  value="{{ $data->gst_no }}" name="gst_no" id="gst_no" class="form-control">
                <span class="kt-form__help error gst_no"></span>
              </div>
              <div class="form-group col-sm-3">
                <label for="total_profit">Remark :-</label>
                <textarea  name="remark" class="form-control" placeholder="Enter Remark">{{ $data->remark }}</textarea>
                <span class="kt-form__help error total_profit"></span>
              </div>
            </div>
            <div class="form-group">
              <button type="submit" class="btn waves-effect waves-light btn-rounded btn-outline-primary">Update</button>
              <a href="{{ route('dealer') }}" class="btn waves-effect waves-light btn-rounded btn-outline-secondary">Back</a>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div> @endsection @section('scripts') <script src="{{ asset('assets/js/promise.min.js') }}"></script>
<script src="{{ asset('assets/js/sweetalert2.bundle.js') }}"></script>
<script>
  $(document).ready(function() {
    var form = $('#form');
    $('.kt-form__help').html('');
    form.submit(function(e) {
      $('.help-block').html('');
      $('.m-form__help').html('');
      $.ajax({
        url: form.attr('action'),
        type: form.attr('method'),
        data: new FormData($(this)[0]),
        dataType: 'json',
        async: false,
        processData: false,
        contentType: false,
        success: function(json) {
          return true;
        },
        error: function(json) {
          if (json.status === 422) {
            e.preventDefault();
            var errors_ = json.responseJSON;
            $('.kt-form__help').html('');
            $.each(errors_.errors, function(key, value) {
              $('.' + key).html(value);
            });
          }
        }
      });
    });
  });
</script> 
@endsection