
@extends('layouts.nav')
@section('title')
@endsection
@section('content')               

<div class="pagetitle">
      <h1>Edit Role</h1>
      
    </div><!-- End Page Title -->
    <section class="section">
      <div class="row">
       
        <div class="col-lg-12">

 
          <div class="card">
            <div class="card-body">
              <h5 class="card-title">Admin roles</h5>

              <!-- No Labels Form -->
              <form action="" style="display:flex; flex-direction:column; gap:20px;" class="row g-3" method="POST">
               {{csrf_field()}}
                <div class="col-md-6">
                  <input type="text" value="{{$getRecord->name}}" name="roleName" class="form-control" placeholder="Role Name">
                </div>
                <div class="col-md-12">
                  <label for="">Permissions</label>
                  <hr>
                  @foreach ($getPermissions as $value)
                    @php
                    $checked = '';
                    @endphp
                    <div style="display: flex; margin-bottom:10px;" class="row">
                      <div class="col-md-3">
                          {{$value["name"]}}
                        </div>
                        <div style="display: flex; gap:30px; text-align:left" class="roles-choose">
                          @foreach ($value["group"] as $group)
                          @php
                                    $checked = '';
                                  @endphp
                              @foreach ($getRolesPermissions as $rolesPermissions)
                                  
                                  @if ($rolesPermissions->permissions_id == $group['id'])
                                  @php
                                    $checked = 'checked';
                                  @endphp
                                  @endif
                              @endforeach
                          <div class="">
                          <label for=""><input type="checkbox" {{$checked}} value="{{$group["id"]}}" name="permission_id[]"> {{$group['name']}}
                          </label>

                          </div>
                          @endforeach
                        </div>

                    </div>
                   <hr>

                    @endforeach
                </div>
                
                <div style="padding-left: 15px; display:flex; gap:20px;" class="">
                    <button type="reset" class="btn btn-secondary">Reset</button>
                  <button type="submit" class="btn btn-primary">Submit</button>
                </div>
              </for><!-- End No Labels Form -->

            </div>
          </div>

        

        </div>
      </div>
    </section>

@endsection