73 lines
2.5 KiB
PHP
73 lines
2.5 KiB
PHP
<div>
|
|
|
|
@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 ($restore_enabled)
|
|
<x-button wire:click="toggleTrashed" type="{{ $trashed ? 'success' : 'warning' }}">
|
|
{{ __($trashed ? 'Show non-deleted records' : 'Show deleted records') }}
|
|
</x-button>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
|
|
<table class="table-auto w-full">
|
|
|
|
<tr class="text-left border-b-2">
|
|
@foreach($columns as $key => $name)
|
|
<th class="border px-6 py-3 w-24">
|
|
@if (isset($sort_columns[$key]))
|
|
<div class="flex items-center justify-between cursor-pointer" wire:click="sort('{{ $key }}')">
|
|
<span class="hover:underline">{{ __($name) }}</span>
|
|
<x-sort-link name="{{ $key }}" :column="$sort" :dir="$dir" class="ml-2 text-gray-600 h-5" />
|
|
</div>
|
|
@else
|
|
{{ $name }}
|
|
@endif
|
|
</th>
|
|
@endforeach
|
|
|
|
@if( (!$trashed && ($delete_enabled || $route_edit)) || ($trashed && $restore_enabled) )
|
|
<th class="border px-6 py-3 w-4">{{ __('Actions') }}</th>
|
|
@endif
|
|
</tr>
|
|
|
|
<tbody>
|
|
@foreach($items as $item)
|
|
<tr class="odd:bg-gray-50">
|
|
@foreach(array_keys($columns) as $key)
|
|
<td class="border px-4 py-2">{{ Arr::get($item, $key) }}</td>
|
|
@endforeach
|
|
|
|
@if (!$trashed && ($route_edit || $delete_enabled))
|
|
<td class="border px-4 py-2">
|
|
@if($route_edit)
|
|
<a href="{{ route($route_edit, [ $item ]) }}">
|
|
<x-icon name="heroicon-o-pencil" class="inline-block w-6 text-yellow-500"/>
|
|
</a>
|
|
@endif
|
|
|
|
@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 && $restore_enabled)
|
|
<td class="border px-4 py-2">
|
|
<x-icon wire:click="restore({{ $item->id }})" name="heroicon-o-refresh" class="cursor-pointer inline-block w-6 text-blue-500"/>
|
|
</td>
|
|
@endif
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
|
|
@if ($items->hasPages())
|
|
<div class="mt-4">
|
|
{{ $items->links() }}
|
|
</div>
|
|
@endif
|
|
|
|
</div>
|