<div class="card-body" id="permission-tables">
    <div class="table-responsive">
        <form action="{{ route('departments.permission-update',$user->id)}}" method="post" enctype='multipart/form-data'>
            @csrf
            @method('patch')
            <table class="table table-bordered align-middle" style="width:100%">
                <thead class="table-light">
                    <tr>
                        <th class="thbutton">Sl No</th>
                        <th>Departments</th>
                        <th class="thbutton">Permissions</th>
                    </tr>
                </thead>
                <tbody>
                    @php $i=1;@endphp
                    @php $checked=1;@endphp
                    @if(count($data)>0)
                        @foreach ($data as $key => $department)
                            <tr>
                                <td>{{$key+1}}</td>
                                <td>{{ $department->name }}</td>
                                <td class="text-center">
                                    <input class="form-check-input{{$i}} btn-lg changeStatusCustom body-checkbox" type="checkbox" id="inlineCheckbox{{$i}}" data-url="{{ route('departments.permission-update',$user->id)}}" data-id="{{$department->id}}" data-status="{{$department->permission == 1 ? '0' : '1'}}" {{ $department->permission == 1 ? 'checked' : ''}}>
                                </td>
                            </tr>
                            @php
                              if ($department->permission == 0) {
                                $checked=0;
                              }
                            @endphp
                        @endforeach
                    @else
                        <tr>
                            <td colspan="5">No Data Found</td>
                        </tr>
                    @endif
                        <input type="hidden" class="form-control check-all" data-status="{{$checked == 1 ? '0' : '1'}}">
                </tbody>
            </table>
            {{--<div class="col-12 mt-3 px-3">
                <button class="btn btn-primary" type="submit"><i class="bx bx-save"></i> Update Permissions</button>
            </div>--}}
        </form>
    </div>
</div>

<script type="text/javascript">
    

</script>