Livewire Datatable: adding delete/restore functionality as livewire actions instead of regular controller actions.
This commit is contained in:
parent
7c49bb8cf7
commit
170a53e473
2 changed files with 58 additions and 22 deletions
|
|
@ -1,12 +1,12 @@
|
|||
<div>
|
||||
|
||||
@if ($route_create || $route_restore)
|
||||
@if ($route_create || $restore_enabled)
|
||||
<div class="flex space-x-4 mb-4">
|
||||
@if ($route_create)
|
||||
<x-button :href="route($route_create)" type="info">{{ __('New') }}</x-button>
|
||||
@endif
|
||||
|
||||
@if ($route_restore)
|
||||
@if ($restore_enabled)
|
||||
<x-button wire:click="toggleTrashed" type="warning">{{ __('Show deleted records') }}</x-button>
|
||||
@endif
|
||||
</div>
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
</th>
|
||||
@endforeach
|
||||
|
||||
@if($route_delete || $route_edit)
|
||||
@if($delete_enabled || $route_edit)
|
||||
<th class="border px-6 py-3 w-4">{{ __('Actions') }}</th>
|
||||
@endif
|
||||
</tr>
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
<td class="border px-4 py-2">{{ Arr::get($item, $key) }}</td>
|
||||
@endforeach
|
||||
|
||||
@if (!$trashed && ($route_edit || $route_delete))
|
||||
@if (!$trashed && ($route_edit || $delete_enabled))
|
||||
<td class="border px-4 py-2">
|
||||
@if($route_edit)
|
||||
<a href="{{ route($route_edit, [ $item ]) }}">
|
||||
|
|
@ -48,19 +48,13 @@
|
|||
</a>
|
||||
@endif
|
||||
|
||||
@if($route_delete)
|
||||
<x-ignite-form class="inline-block" id="dt-delete-{{$_instance->id}}-{{ $item->id }}" method="DELETE" action="{{ route($route_delete, [ $item ]) }}">
|
||||
<a href="javascript:document.getElementById('dt-delete-{{$_instance->id}}-{{ $item->id }}').submit();">
|
||||
<x-icon name="heroicon-o-trash" class="inline-block w-6 text-red-500"/>
|
||||
</a>
|
||||
</x-ignite-form>
|
||||
@if ($delete_enabled)
|
||||
<x-icon wire:click="delete({{ $item->id }})" name="heroicon-o-trash" class="cursor-pointer inline-block w-6 text-red-500"/>
|
||||
@endif
|
||||
</td>
|
||||
@elseif ($trashed && $route_restore)
|
||||
@elseif ($trashed && $restore_enabled)
|
||||
<td class="border px-4 py-2">
|
||||
<a href="{{ route($route_restore, [ $item ]) }}">
|
||||
<x-icon name="heroicon-o-refresh" class="inline-block w-6 text-blue-500"/>
|
||||
</a>
|
||||
<x-icon wire:click="restore({{ $item->id }})" name="heroicon-o-refresh" class="cursor-pointer inline-block w-6 text-blue-500"/>
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
|
|
|
|||
Reference in a new issue