index.blade.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. @extends($rbacLayout)
  2. @section('title', __('rbac::users.users'))
  3. @section('content')
  4. <section class="content container-fluid">
  5. @if ($errors->has('items'))
  6. <div class="row">
  7. <div class="col-12 col-md-10 offset-md-1 col-lg-8 offset-lg-2 col-xl-6 offset-xl-3 text-center">
  8. <div class="alert alert-danger px-3 py-2" role="alert">
  9. <strong>{{ $errors->first('items') }}</strong>
  10. </div>
  11. </div>
  12. </div>
  13. @endif
  14. @php
  15. $gridData = [
  16. 'dataProvider' => $dataProvider,
  17. 'paginatorOptions' => [
  18. 'pageName' => 'p',
  19. ],
  20. 'rowsPerPage' => $rbacRowsPerPage,
  21. 'title' => __('rbac::users.users'),
  22. 'rowsFormAction' => route('delete_user'),
  23. 'columnFields' => [
  24. [
  25. 'label' => 'ID',
  26. 'attribute' => 'memberKey',
  27. 'htmlAttributes' => [
  28. 'width' => '5%',
  29. ],
  30. 'filter' => false,
  31. 'sort' => $authIdentifierName
  32. ],
  33. [
  34. 'label' => __('rbac::users.name'),
  35. 'value' => function ($user) {
  36. return '<a href="' . route('show_user', ['id' => $user->memberKey]) . '">' . $user->memberName .'</a>';
  37. },
  38. 'filter' => [
  39. 'class' => Itstructure\GridView\Filters\TextFilter::class,
  40. 'name' => 'name'
  41. ],
  42. 'sort' => 'name',
  43. 'format' => 'html',
  44. ],
  45. [
  46. 'label' => __('rbac::roles.roles'),
  47. 'value' => function ($user) {
  48. $output = '<ul class="list-group list-group-flush">';
  49. foreach($user->roles as $role) {
  50. $output .= '<li class="list-group-item p-2"><a href="' . route('show_role', ['id' => $role->id]) . '">' . $role->name . '</a></li>';
  51. }
  52. return $output . '</ul>';
  53. },
  54. 'filter' => false,
  55. 'sort' => false,
  56. 'format' => 'html',
  57. ],
  58. [
  59. 'label' => __('rbac::main.created'),
  60. 'attribute' => 'created_at',
  61. 'filter' => false,
  62. ],
  63. [
  64. 'class' => Itstructure\GridView\Columns\ActionColumn::class,
  65. 'actionTypes' => [
  66. 'view' => function ($user) {
  67. return route('show_user', ['id' => $user->memberKey]);
  68. },
  69. 'edit' => function ($user) {
  70. return route('edit_user', ['id' => $user->memberKey]);
  71. }
  72. ],
  73. 'htmlAttributes' => [
  74. 'width' => '130',
  75. ],
  76. ],
  77. [
  78. 'class' => Itstructure\GridView\Columns\CheckboxColumn::class,
  79. 'field' => 'items',
  80. 'attribute' => 'memberKey',
  81. 'display' => function ($user) {
  82. return Gate::allows(Itstructure\LaRbac\Models\Permission::DELETE_MEMBER_FLAG, $user->memberKey);
  83. }
  84. ],
  85. ],
  86. ];
  87. @endphp
  88. @gridView($gridData)
  89. </section>
  90. @endsection