What seems to be the problem:
I guys, using livewire 2.0, I have a strange issue with a dual header table : I create and hydrate the table but when i make a first update, the initale(s) value for a given row and first order column are lost…
Here is an example:
(1) = The table after mount
(2) If I click to add the documents.create permission to the administrator, it works like a charm
(3) But now, if I click to add the roles.modify permission to the administrator, here is what happends:
The roles.create has disappeared
here is my blade :
<table class="table-auto w-full text-left border-collapse"> <thead>
<tr class="">
<th></th>
@foreach($festivalPermissions as $feature)
<th
colspan="{{count($feature)}}"
>
{{ __($feature[0]['feature'])}}
</th>
@endforeach
</tr>
<tr>
<th></th>
@foreach($festivalPermissions as $feature)
@foreach($feature as $permission)
<th>{{ __($permission['action'])}}</th>
@endforeach
@endforeach
</tr>
</thead>
<tbody>
@foreach($roles as $role)
<tr>
<th>{{ explode('_',$role->name)[1] }}</th>
@foreach($festivalPermissions as $feature)
@foreach($feature as $permission)
<td>
<input
wire:model='rolePermissions.{{ $role->name}}.{{$permission['feature']}}.{{$permission['action']}}'
wire:key='{{ $role->name}}.{{$permission['feature']}}.{{$permission['action']}}.{{ $loop->index }}''
type="checkbox"
>
</td>
@endforeach
@endforeach
</tr>
@endforeach
</tbody>
</table>
And my update function:
public function updated($propertyName)
{
$properties = explode('.',$propertyName);
if ($properties[0] == 'rolePermissions')
{
$role=Role::where('name',$properties[1])->first();
if($role->hasPermissionTo($properties[2].'.'.$properties[3]))
{
$role->revokePermissionTo($properties[2].'.'.$properties[3]);
}
else
{
$role->givePermissionTo($properties[2].'.'.$properties[3]);
}
}
}
Thanks for your advises !