edit.blade.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. @extends('layouts.admin.app')
  2. @section('content')
  3. <!-- Main content -->
  4. <section class="content">
  5. @include('layouts.errors-and-messages')
  6. <div class="box">
  7. <form action="{{ route('admin.addresses.update', $address->id) }}" method="post" class="form" enctype="multipart/form-data">
  8. <div class="box-body">
  9. {{ csrf_field() }}
  10. <input type="hidden" name="_method" value="put">
  11. <div class="form-group">
  12. <label for="customer">Customers </label>
  13. <input type="hidden" name="customer" value="">
  14. <select name="customer" id="status" class="form-control">
  15. @foreach($customers as $customer)
  16. @if($customer->id == $customerId)
  17. <option selected="selected" value="{{ $customer->id }}">{{ $customer->name }}</option>
  18. @else
  19. <option value="{{ $customer->id }}">{{ $customer->name }}</option>
  20. @endif
  21. @endforeach
  22. </select>
  23. </div>
  24. <div class="form-group">
  25. <label for="alias">Alias <span class="text-danger">*</span></label>
  26. <input type="text" name="alias" id="alias" placeholder="Home or Office" class="form-control" value="{{ $address->alias ?: old('alias') }}">
  27. </div>
  28. <div class="form-group">
  29. <label for="address_1">Address 1 <span class="text-danger">*</span></label>
  30. <input type="text" name="address_1" id="address_1" placeholder="Address 1" class="form-control" value="{{ $address->address_1 ?: old('address_1') }}">
  31. </div>
  32. <div class="form-group">
  33. <label for="address_2">Address 2 </label>
  34. <input type="text" name="address_2" id="address_2" placeholder="Address 2" class="form-control" value="{{ $address->address_2 ?: old('address_2') }}">
  35. </div>
  36. <div class="form-group">
  37. <label for="country_id">Country </label>
  38. <select name="country_id" id="country_id" class="form-control">
  39. @foreach($countries as $country)
  40. @if($country->id == $countryId)
  41. <option selected="selected" value="{{ $country->id }}">{{ $country->name }}</option>
  42. @else
  43. <option value="{{ $country->id }}">{{ $country->name }}</option>
  44. @endif
  45. @endforeach
  46. </select>
  47. </div>
  48. <div class="form-group">
  49. <label for="province_id">Province </label>
  50. <select name="province_id" id="province_id" class="form-control">
  51. @foreach($provinces as $province)
  52. @if($province->id == $provinceId)
  53. <option selected="selected" value="{{ $province->id }}">{{ $province->name }}</option>
  54. @else
  55. <option value="{{ $province->id }}">{{ $province->name }}</option>
  56. @endif
  57. @endforeach
  58. </select>
  59. </div>
  60. <div id="cities" class="form-group">
  61. <label for="city_id">City </label>
  62. <select name="city_id" id="city_id" class="form-control">
  63. @foreach($cities as $city)
  64. @if($city->id == $cityId)
  65. <option selected="selected" value="{{ $city->id }}">{{ $city->name }}</option>
  66. @else
  67. <option value="{{ $city->id }}">{{ $city->name }}</option>
  68. @endif
  69. @endforeach
  70. </select>
  71. </div>
  72. <div class="form-group">
  73. <label for="zip">Zip Code </label>
  74. <input type="text" name="zip" id="zip" placeholder="Zip code" class="form-control" value="{{ $address->zip ?: old('zip') }}">
  75. </div>
  76. <div class="form-group">
  77. @include('admin.shared.status-select', ['status' => $address->status])
  78. </div>
  79. </div>
  80. <!-- /.box-body -->
  81. <div class="box-footer">
  82. <div class="btn-group">
  83. <a href="{{ route('admin.addresses.index') }}" class="btn btn-default">Back</a>
  84. <button type="submit" class="btn btn-primary">Update</button>
  85. </div>
  86. </div>
  87. </form>
  88. </div>
  89. <!-- /.box -->
  90. </section>
  91. <!-- /.content -->
  92. @endsection
  93. @section('js')
  94. <script type="text/javascript">
  95. $(document).ready(function () {
  96. $('#province_id').change(function () {
  97. var provinceId = $(this).val();
  98. $.ajax({
  99. url: '/api/v1/country/169/province/' + provinceId + '/city',
  100. contentType: 'json',
  101. success: function (data) {
  102. var html = '<label for="city_id">City </label>';
  103. html += '<select name="city_id" id="city_id" class="form-control">';
  104. $(data.data).each(function (idx, v) {
  105. html += '<option value="'+ v.id+'">'+ v.name +'</option>';
  106. });
  107. html += '</select>';
  108. $('#cities').html(html).show();
  109. },
  110. errors: function (data) {
  111. console.log(data);
  112. }
  113. });
  114. });
  115. });
  116. </script>
  117. @endsection