within my controller, I obtain a list of roles with their associated permissions. Additionally, I obtain a list of all permissions.
$roles = Role::with('perms')->get();
$permissions = Permission::all();
So now when I pass this to my view, I now have a list of roles with their permissions, and a list of all possible permissions.
Within my view, I am currently doing something like this
@foreach($roles as $role)
<tr>
<td>
</td>
<td>
<ul class="list-group">
@foreach($role->perms as $permission)
<li class="list-group-item">
</li>
@endforeach
</ul>
</td>
</tr>
@endforeach
So I am essentially displaying all roles with their permissions. Now, within each loop, I am trying to add something like the following
<li class="list-group-item">
<select name="add-permission-select" class="form-control"></select>
</li>
The above select should display all remaining permissions a role can have. So I essentially need to see all the permissions a role has, and then cross check this against my $permissions list. So lets say I have
PermissionA
PermissionB
PermissionC
And the first role only has PermissionA, the select options for this role should display PermissionB and PermissionC.
How would I go about cross comparing the two things?
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire