index.blade.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. @extends('admin.table_layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h2 class="panel-title">{{ trans('admin.menu.user.group') }} <small>{{ trans('admin.user.group.sub_title') }}</small></h2>
  7. @can('admin.user.group.create')
  8. <div class="panel-actions">
  9. <a class="btn btn-primary" href="{{ route('admin.user.group.create') }}">
  10. <i class="icon wb-plus" aria-hidden="true"></i> {{ trans('common.add') }}
  11. </a>
  12. </div>
  13. @endcan
  14. </div>
  15. <div class="panel-body">
  16. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  17. <thead class="thead-default">
  18. <tr>
  19. <th> #</th>
  20. <th> {{ trans('admin.user.group.name') }}</th>
  21. <th> {{ trans('common.action') }}</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. @foreach ($groups as $group)
  26. <tr>
  27. <td> {{ $group->id }} </td>
  28. <td> {{ $group->name }} </td>
  29. <td>
  30. @canany(['admin.user.group.edit', 'admin.user.group.destroy'])
  31. <div class="btn-group">
  32. @can('admin.user.group.edit')
  33. <a class="btn btn-primary" href="{{ route('admin.user.group.edit', $group) }}">
  34. <i class="icon wb-edit" aria-hidden="true"></i>
  35. </a>
  36. @endcan
  37. @can('admin.user.group.destroy')
  38. <button class="btn btn-danger"
  39. onclick="deleteUserGroup('{{ route('admin.user.group.destroy', $group) }}', '{{ $group->name }}')">
  40. <i class="icon wb-trash" aria-hidden="true"></i>
  41. </button>
  42. @endcan
  43. </div>
  44. @endcanany
  45. </td>
  46. </tr>
  47. @endforeach
  48. </tbody>
  49. </table>
  50. </div>
  51. <div class="panel-footer">
  52. <div class="row">
  53. <div class="col-sm-4">
  54. {!! trans('admin.user.group.counts', ['num' => $groups->total()]) !!}
  55. </div>
  56. <div class="col-sm-8">
  57. <nav class="Page navigation float-right">
  58. {{ $groups->links() }}
  59. </nav>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. @endsection
  66. @push('javascript')
  67. @can('admin.user.group.edit')
  68. <script>
  69. // 删除用户分组
  70. function deleteUserGroup(url, name) {
  71. swal.fire({
  72. title: '{{ trans('admin.hint') }}',
  73. text: '{{ trans('admin.confirm.delete.0', ['attribute' => trans('model.user_group.attribute')]) }}' +
  74. name + '{{ trans('admin.confirm.delete.1') }}',
  75. icon: "info",
  76. showCancelButton: true,
  77. cancelButtonText: '{{ trans('common.close') }}',
  78. confirmButtonText: '{{ trans('common.confirm') }}'
  79. }).then((result) => {
  80. if (result.value) {
  81. $.ajax({
  82. method: "DELETE",
  83. url: url,
  84. data: {
  85. _token: '{{ csrf_token() }}'
  86. },
  87. dataType: "json",
  88. success: function(ret) {
  89. if (ret.status === "success") {
  90. swal.fire({
  91. title: ret.message,
  92. icon: "success",
  93. timer: 1000,
  94. showConfirmButton: false
  95. }).then(() => window.location.reload());
  96. } else {
  97. swal.fire({
  98. title: ret.message,
  99. icon: "error"
  100. }).then(() => window.location.reload());
  101. }
  102. }
  103. });
  104. }
  105. });
  106. }
  107. </script>
  108. @endcan
  109. @endpush