index.blade.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. @extends($rbacLayout)
  2. @section('title', __('rbac::roles.roles'))
  3. @section('content')
  4. <section class="content container-fluid">
  5. <p><a class="btn btn-success" href="{{ route('create_role') }}">{!! __('rbac::roles.create_role') !!}</a></p>
  6. @if ($errors->has('items'))
  7. <div class="row">
  8. <div class="col-12 col-md-10 offset-md-1 col-lg-8 offset-lg-2 col-xl-6 offset-xl-3 text-center">
  9. <div class="alert alert-danger px-3 py-2" role="alert">
  10. <strong>{{ $errors->first('items') }}</strong>
  11. </div>
  12. </div>
  13. </div>
  14. @endif
  15. @php
  16. $gridData = [
  17. 'dataProvider' => $dataProvider,
  18. 'paginatorOptions' => [
  19. 'pageName' => 'p',
  20. ],
  21. 'rowsPerPage' => $rbacRowsPerPage,
  22. 'title' => __('rbac::roles.roles'),
  23. 'rowsFormAction' => route('delete_role'),
  24. 'columnFields' => [
  25. [
  26. 'label' => 'ID',
  27. 'attribute' => 'id',
  28. 'htmlAttributes' => [
  29. 'width' => '5%',
  30. ],
  31. 'filter' => false
  32. ],
  33. [
  34. 'label' => __('rbac::main.name'),
  35. 'value' => function ($role) {
  36. return '<a href="' . route('show_role', ['id' => $role->id]) . '">' . $role->name .'</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::main.slug'),
  47. 'attribute' => 'slug',
  48. ],
  49. [
  50. 'label' => __('rbac::main.description'),
  51. 'attribute' => 'description',
  52. 'filter' => false,
  53. 'sort' => false
  54. ],
  55. [
  56. 'label' => __('rbac::permissions.permissions'),
  57. 'value' => function ($role) {
  58. $output = '<ul class="list-group list-group-flush">';
  59. foreach($role->permissions as $permission) {
  60. $output .= '<li class="list-group-item p-2"><a href="' . route('show_permission', ['id' => $permission->id]) . '">' . $permission->name . '</a></li>';
  61. }
  62. return $output . '</ul>';
  63. },
  64. 'filter' => false,
  65. 'sort' => false,
  66. 'format' => 'html',
  67. ],
  68. [
  69. 'label' => __('rbac::main.created'),
  70. 'attribute' => 'created_at',
  71. 'filter' => false,
  72. ],
  73. [
  74. 'class' => Itstructure\GridView\Columns\ActionColumn::class,
  75. 'actionTypes' => [
  76. 'view' => function ($role) {
  77. return route('show_role', ['id' => $role->id]);
  78. },
  79. 'edit' => function ($role) {
  80. return route('edit_role', ['role' => $role->id]);
  81. }
  82. ],
  83. 'htmlAttributes' => [
  84. 'width' => '130',
  85. ],
  86. ],
  87. [
  88. 'class' => Itstructure\GridView\Columns\CheckboxColumn::class,
  89. 'field' => 'items',
  90. 'attribute' => 'id'
  91. ],
  92. ],
  93. ];
  94. @endphp
  95. @gridView($gridData)
  96. </section>
  97. @endsection