index.blade.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. @extends('backend.layouts.app')
  2. @section('content')
  3. <div class="card">
  4. <form class="" id="" action="" method="GET">
  5. <div class="card-header row gutters-5">
  6. <div class="col text-center text-md-left">
  7. <h5 class="mb-md-0 h6">{{ translate('Countries') }}</h5>
  8. </div>
  9. <div class="col-md-3">
  10. <input type="text" class="form-control" id="sort_country" name="sort_country" @isset($sort_country) value="{{ $sort_country }}" @endisset placeholder="{{ translate('Type country name') }}">
  11. </div>
  12. <div class="col-md-1">
  13. <button class="btn btn-primary" type="submit">{{ translate('Filter') }}</button>
  14. </div>
  15. </div>
  16. </form>
  17. <div class="card-body">
  18. <table class="table aiz-table table-striped table-bordered" cellspacing="0" width="100%">
  19. <thead>
  20. <tr>
  21. <th width="10%">#</th>
  22. <th>{{translate('Name')}}</th>
  23. <th data-breakpoints="lg">{{translate('Code')}}</th>
  24. <th>{{translate('Show/Hide')}}</th>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. @foreach($countries as $key => $country)
  29. <tr>
  30. <td>{{ ($key+1) + ($countries->currentPage() - 1)*$countries->perPage() }}</td>
  31. <td>{{ $country->name }}</td>
  32. <td>{{ $country->code }}</td>
  33. <td>
  34. <label class="aiz-switch aiz-switch-success mb-0">
  35. <input onchange="update_status(this)" value="{{ $country->id }}" type="checkbox" <?php if($country->status == 1) echo "checked";?> >
  36. <span class="slider round"></span>
  37. </label>
  38. </td>
  39. </tr>
  40. @endforeach
  41. </tbody>
  42. </table>
  43. <div class="aiz-pagination">
  44. {{ $countries->links() }}
  45. </div>
  46. </div>
  47. </div>
  48. @endsection
  49. @section('script')
  50. <script type="text/javascript">
  51. function update_status(el){
  52. if(el.checked){
  53. var status = 1;
  54. }
  55. else{
  56. var status = 0;
  57. }
  58. $.post('{{ route('countries.status') }}', {_token:'{{ csrf_token() }}', id:el.value, status:status}, function(data){
  59. if(data == 1){
  60. AIZ.plugins.notify('success', '{{ translate('Country status updated successfully') }}');
  61. }
  62. else{
  63. AIZ.plugins.notify('danger', '{{ translate('Something went wrong') }}');
  64. }
  65. });
  66. }
  67. </script>
  68. @endsection