Skip to content

Commit

Permalink
added wire:key to loops
Browse files Browse the repository at this point in the history
  • Loading branch information
dcblogdev committed May 29, 2024
1 parent fb7f961 commit 2e9bd4d
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 33 deletions.
19 changes: 14 additions & 5 deletions resources/views/components/form/checkbox.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
'id' => '',
'label' => '',
'value' => '',
'selected' => ''
'selected' => '',
'class' => 'block cursor-pointer',
])

@php
Expand All @@ -25,7 +26,15 @@
@endphp
@endif

<div>
<input type='checkbox' name='{{ $name }}' id='{{ $id }}' value='{{ $value }}' @if ($selected === $value) checked='checked' @endif {{ $attributes }}>
<label for='{{ $id }}'>{{ $label }}</label>
</div>
<label for='{{ $id }}' wire:key="{{ $id }}" class="{{ $class }}">
<div class="flex gap-2">
<input
type="checkbox"
name='{{ $name }}'
id='{{ $id }}'
value='{{ $value }}'
@if ($selected === $value) checked='checked' @endif {{ $attributes }}
>
{{ $label }}
</div>
</label>
2 changes: 1 addition & 1 deletion resources/views/livewire/admin/audit-trails.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class="bg-gray-200 dark:bg-gray-700 rounded-b-md p-5"
</thead>
<tbody>
@foreach($this->userlogs() as $log)
<tr>
<tr wire:key="{{ $log->id }}">
<td>{{ $log->user->name ?? '' }}</td>
<td>{{ $log->title }}</td>
<td>{{ $log->section }}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<li class="p-6">{{ __('No notifications yet.') }}</li>
@else
@foreach($notifications as $notification)
<li class="px-6 py-5 relative">
<li wire:key="{{ $notification->id }}" class="px-6 py-5 relative">
<div class="group flex justify-between items-center">
@if (!empty($notification->link))
<x-a href="{{ $notification->link }}" class="-m-1 p-1 block">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/admin/roles/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</thead>
<tbody>
@foreach($this->roles() as $role)
<tr>
<tr wire:key="{{ $role->id }}">
<td>{{ $role->label }}</td>
<td>
<div class="flex space-x-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</tr>
@foreach($ips as $index => $row)
@error("ips.$index.ip")
<tr>
<tr wire:key="{{ $index }}">
<td colspan="3">
<span class="error">{{ $message }}</span>
</td>
Expand All @@ -28,7 +28,7 @@
<tr>
<td><x-form.input wire:model.live="ips.{{ $index }}.ip" label="none">{{ $row['ip'] }}</x-form.input></td>
<td><x-form.input wire:model.live="ips.{{ $index }}.comment" label="none">{{ $row['comment'] }}</x-form.input></td>
<td class="flex justify-center pt-2"><button type="button" wire:click="remove({{ $index }})" class="error">X</button></td>
<td class="flex justify-center pt-2"><button type="button" wire:click="remove({{ $index }})" wire:confirm="Are you sure?" class="error">X</button></td>
</tr>
@endforeach
</table>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/admin/users/activity.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class="bg-gray-200 dark:bg-gray-700 rounded-b-md p-5"
</thead>
<tbody>
@foreach($this->userlogs() as $log)
<tr>
<tr wire:key="{{ $log->id }}">
<td>{{ $log->title }}</td>
<td>{{ $log->section }}</td>
<td>{{ $log->type }}</td>
Expand Down
18 changes: 7 additions & 11 deletions resources/views/livewire/admin/users/edit/roles.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
<x-form wire:submit="update" method="put">

@foreach($roles as $role)
<label class="block cursor-pointer">
<div class="flex gap-2">
<input
type="checkbox"
wire:model.live="roleSelections"
value="{{ $role->id }}"
>
{{ $role->label }}
</div>
</label>
<x-form.checkbox
wire:model.live="roleSelections"
id="{{ $role->id }}"
value="{{ $role->id }}"
label="{{ $role->label }}"
/>
@endforeach

<x-button class="mt-5">{{ __('Update Roles') }}</x-button>
Expand All @@ -32,4 +28,4 @@
</x-slot>
</x-2col>

</div>
</div>
2 changes: 1 addition & 1 deletion resources/views/livewire/admin/users/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class="bg-gray-200 dark:bg-gray-700 rounded-b-md p-5"
</thead>
<tbody>
@foreach($this->users() as $user)
<tr>
<tr wire:key="{{ $user->id }}">
<td class="flex">
<div>
@if (storage_exists($user->image))
Expand Down
16 changes: 6 additions & 10 deletions resources/views/livewire/admin/users/invite.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@
@enderror

@foreach($roles as $role)
<label class="block cursor-pointer">
<div class="flex gap-2">
<input
type="checkbox"
wire:model="rolesSelected"
value="{{ $role->name }}"
>
{{ $role->label }}
</div>
</label>
<x-form.checkbox
wire:model.live="rolesSelected"
id="{{ $role->id }}"
value="{{ $role->id }}"
label="{{ $role->label }}"
/>
@endforeach

</x-slot>
Expand Down

0 comments on commit 2e9bd4d

Please sign in to comment.