@extends('layout.app')


@section('content')


<div class="card">

    <div class="card-body">
        <form action="{{ route('permissionUpdate',$role->id) }}" method="POST">
            @method('PUT')
            @csrf

            
            <h2 class="page-header">Role Name :
              
                {{ $role->name }}</h2>

                {{-- {{dd($role)}} --}}
                <div class="">
                <table class="table table-border table-striped">
                  {{-- <tr>
                    
                    <th>ID</th>
                    <th>Permission Name</th>
                    <th></th>
                  </tr> --}}

                  <input type="hidden" name="name" value="{{ $role->name }}">
                  <input type="hidden" name="id" value="{{ $role->id }}">
                  <div class="row">

                 
                  @foreach($permisssions as $p )

                  <div class="col-md-3">
                   
                    <div class="form-group" style="padding-top:15px;display:inline-block">
                      <div class="custom-control custom-switch">
                        {{-- <input type="checkbox" class="custom-control-input" id="customSwitch1"> --}}
                        
                        <input class="pcheck custom-control-input" id="permission{{$p->id}}" name="permissions[]" type="checkbox" value="{{ $p->id }}"
                        @if( $role->hasPermissionTo($p->id))
                        {{ 'checked' }}
                        @endif
                        >
                        <label class="custom-control-label" for="permission{{$p->id}}"></label>
                      </div>
                      
                    </div>
                    <span style="margin-left:90px">
                      ({{ $p->id }}) {{ $p->name }}
                    </span>

                  </div>

                  
                  {{-- <tr style="display: none">
                    
                    <td>{{ $p->id }}</td>
                    <td>{{ $p->name }}</td>
                    <td>

                      <div class="form-group">

                        <div class="custom-control custom-switch">                          
                          
                          <input class="pcheck custom-control-input" id="permission{{$p->id}}" name="permissions[]" type="checkbox" value="{{ $p->id }}"
                          @if( $role->hasPermissionTo($p->id))
                          {{ 'checked' }}
                          @endif
                          >
                          <label class="custom-control-label" for="permission{{$p->id}}"></label>
                        </div>
                        
                      </div>



                      
                      
                
                    </td>
                  </tr> --}}
                  @endforeach
                </div>

                </table>
                </div>

           



            <div class="form-group">
                <a href="{{route('roles.index')}}" class="btn btn-default"><i class="fa fa-arrow-left"></i> Back</a>
                <input type="submit" class="btn btn-primary float-right"
                value="Assign Permission">
            </div>


        </form>
    </div>
</div>



@endsection
