<form id="form-staff-permission">
    <table class="table table-bordered table-striped">
        <input type="hidden" name="id" value="{{ $user->id }}"/>
        <tbody>
        @foreach(config('permissions') as $item)
        <tr>
            <td> {{ $item['name'] }}</td>
            <td>
                <div class="mt-checkbox-inline">
                    <label class="mt-checkbox">
                        <input type="checkbox" class="check-all"> Tất cả
                        <span></span>
                    </label>
                    @foreach($item['permissions'] as $perm )
                    <label class="mt-checkbox">
                        <input type="checkbox" name="permissions[]" value="{{ $perm['name'] }}"
                               @if($user->hasPermissionTo($perm['name'])) checked @endif> {{ $perm['display_name'] }}
                        <span></span>
                    </label>
                    @endforeach


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

        <tr>
            <td> Phân quyền theo nhà trọ</td>
            <td>
                @php $hostels = \App\Models\Hostel::where('owner_id', auth('backend')->user()->id)->get();
                    $hostelArrs = $user->staffHostelArr->pluck('hostel_id')->toArray();
                @endphp

                <div class="mt-checkbox-inline">
                    @foreach($hostels as $hostel)
                        <label class="mt-checkbox">
                            <input type="checkbox" class="check-hostel" name="hostels[]" value="{{ $hostel->id }}"

                                   @if(!empty($hostelArrs))
                                   @if(in_array($hostel->id, $hostelArrs))checked
                                    @endif
                                    @endif


                            > {{ $hostel->name }}
                            <span></span>
                        </label>
                    @endforeach
                    <label class="mt-checkbox">
                        <input type="checkbox" class="check-hostel check-all" id="all" name="hostels[]" value="-1"
                               @if(!empty($hostelArrs))
                               @if(in_array($hostel->id, $hostelArrs))checked
                                @endif
                                @endif> Tất cả
                        <span></span>
                    </label>
                </div>
            </td>
        </tr>
        </tbody>
    </table>
    <!--end profile-settings-->
</form>