add.blade.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. @extends('admin.layout.index')
  2. @push('css-head')
  3. @endpush
  4. @section('content')
  5. <!-- Page header -->
  6. <div class="page-header page-header-light">
  7. <div class="breadcrumb-line breadcrumb-line-light header-elements-md-inline">
  8. <div class="d-flex">
  9. <div class="breadcrumb">
  10. <a href="{{url('/admin')}}" class="breadcrumb-item"><i class="icon-home2 mr-2"></i> Dashboard</a>
  11. <a href="{{url('/admin/roles')}}" class="breadcrumb-item"> Roles</a>
  12. <span class="breadcrumb-item active">Create New</span>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. <!-- /page header -->
  18. <!-- Content area -->
  19. <div class="content">
  20. <div class="card">
  21. <div class="card-body">
  22. @if (count($errors) > 0)
  23. <div class="alert alert-danger alert-no-border alert-txt-colored alert-close alert-dismissible fade show" role="alert">
  24. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  25. <span aria-hidden="true">×</span>
  26. </button>
  27. <strong>Whoops!</strong> There were some problems with your input.
  28. <ul>
  29. @foreach ($errors->all() as $error)
  30. <li>{{ $error }}</li>
  31. @endforeach
  32. </ul>
  33. </div>
  34. @endif
  35. {!!Form::open(array('url'=>'admin/roles/store','method'=>'POST'))!!}
  36. <div class="form-group">
  37. <label>Name:</label>
  38. <input type="text" class="form-control" name="name" id="name" placeholder="Name" required="">
  39. </div>
  40. <br>
  41. @foreach($permissions as $key=>$row)
  42. <div class="card mb-1">
  43. <div class="card-header header-elements-inline">
  44. <h6 class="card-title">
  45. <div class="custom-control custom-checkbox">
  46. <input type="checkbox" class="custom-control-input parent" id="check-{{$row['parent']->id}}" name="permissions[]" value="{{$row['parent']->id}}">
  47. <label class="custom-control-label font-weight-semibold" for="check-{{$row['parent']->id}}">{{$row['parent']->display_name}}</label>
  48. </div>
  49. </h6>
  50. <div class="header-elements">
  51. @if(count($row['childs']) > 0)
  52. <div class="custom-control custom-checkbox" onclick="checkAll(this);">
  53. <input type="checkbox" class="custom-control-input" id="select-{{$key}}">
  54. <label class="custom-control-label" for="select-{{$key}}">Select all</label>
  55. </div>
  56. @endif
  57. </div>
  58. </div>
  59. @if(count($row['childs']) > 0)
  60. <div class="card-body" style="padding: 10px 20px; background: #f9f9f9;">
  61. <div class="row">
  62. @foreach($row['childs'] as $child)
  63. <div class="col-lg-4">
  64. <div class="custom-control custom-checkbox">
  65. <input type="checkbox" class="custom-control-input" id="check-{{$child->id}}" name="permissions[]" value="{{$child->id}}" onclick="checkParent(this);">
  66. <label class="custom-control-label font-weight-semibold" for="check-{{$child->id}}">{{$child->display_name}}</label>
  67. </div>
  68. </div>
  69. @endforeach
  70. </div>
  71. </div>
  72. @endif
  73. </div>
  74. @endforeach.
  75. <br>
  76. <div class="text-right">
  77. <a href="{{ url('admin/roles/create') }}" class="btn btn-secondary pull-left">
  78. Refresh
  79. <i class="icon-reload-alt ml-2"></i>
  80. </a>
  81. <button type="submit" class="btn btn-primary">Submit <i class="icon-paperplane ml-2"></i></button>
  82. </div>
  83. {!! Form::close() !!}
  84. </div>
  85. </div>
  86. </div>
  87. <!-- /content area -->
  88. @endsection
  89. @push('scripts')
  90. <script type="text/javascript">
  91. function checkAll(now){
  92. var check = $(now).find('input[type = "checkbox"]').prop("checked");
  93. if(check == true){
  94. $(now).closest('.card').find('input[type = "checkbox"]').attr('checked', 'checked');
  95. }else{
  96. $(now).closest('.card').find('input[type = "checkbox"]').removeAttr('checked', 'checked');
  97. }
  98. }
  99. function checkParent(now){
  100. var check = $(now).prop("checked");
  101. if(check == true){
  102. var parent = $(now).closest('.card').find('.parent').prop("checked");
  103. if(parent == false){
  104. $(now).closest('.card').find('.parent').attr('checked', 'checked');
  105. }
  106. }
  107. }
  108. </script>
  109. @endpush