Selected Checkbox

Hi Guys
Im having issues trying to display a list of permissions from the database and then trying to edit the role and its permissions, i cannot get the form to have the permissions assigned to the role to be checked.

PHP:

public $role;

public $permissions

public $permissionList;

public function render(PermissionService $permissionService)
{
    $this->permissionList = $permissionService->getPermissions();
    $this->permissions = $permissionService->getRolePermissions($this->role);

    return view('livewire.roles.edit');
}

VIEW:

@foreach($permissionList as $key => $permission)
       <div class="form-row">
            <div class="form-group col-md-6 h5">
                {{ ucfirst($key) }}
             </div>
            <div class="form-group col-md-6">
             @foreach($permission as $item)
               <div>
                  <input type="checkbox" id="{{ $item['id'] }}" name="{{ $item['id'] }}" value="{{ $item['id'] }}" wire:model="permissions.{{ $item['id'] }}"/> {{ ucfirst($item['name']) }}
                </div>
             @endforeach
         </div>
         <hr/>
    </div>
   @endforeach

PermissionList Array:

array:4 [▼
  "administration" => array:1 [▼
    0 => array:2 [▼
      "id" => 15
      "name" => "preferences"
    ]
  ]
  "users" => array:5 [▼
    1 => array:2 [▼
      "id" => 16
      "name" => "view"
    ]
    2 => array:2 [▼
      "id" => 17
      "name" => "create"
    ]
    3 => array:2 [▼
      "id" => 18
      "name" => "edit"
    ]
    4 => array:2 [▼
      "id" => 19
      "name" => "delete"
    ]
    5 => array:2 [▼
      "id" => 20
      "name" => "impersonate"
    ]
  ]

I made the permissions list array to have a category and the permissions assigned to that category, purely for display purposes.

I have tried to make the $permissions the same as the list array and also make it $permission = [‘permissions.15’]; or $permission = [15] etc but i cannot get the permissions assigned to the role be selected.

Any help would be greatly appreciated.
Thanks

OK I just had to make the returned array use the id as the index and then you don’t need to do the foreach for the checked and everything works as expected.

array:4 [▼
  "administration" => array:1 [▼
15 => array:2 [▼
  "name" => "preferences"
   ]
 ]
 "users" => array:5 [▼
16 => array:2 [▼
  "name" => "view"
]
17 => array:2 [▼
  "name" => "create"
]
18 => array:2 [▼
  "name" => "edit"
]
19 => array:2 [▼
  "name" => "delete"
]

View:

@foreach($permissionList as $key => $permission)
   <div class="form-row">
        <div class="form-group col-md-6 h5">
            {{ ucfirst($key) }}
         </div>
        <div class="form-group col-md-6">
         @foreach($permission as $index => $item)
           <div>
              <input type="checkbox" id="{{ $index }}" name="{{ $index }}" value="1" wire:model="permissions.{{ $key }}.{{ $index }}"/> {{ ucfirst($item['name']) }}
            </div>
         @endforeach
     </div>
     <hr/>
</div>
@endforeach