cms-laravel/resources/views/livewire/table-layout.blade.php

75 lines
3.2 KiB
PHP

<div class="container mx-auto py-6">
@if (session()->has('success'))
<div class="alert alert-success mb-4">{{ session('success') }}</div>
@endif
@if (session()->has('error'))
<div class="alert alert-danger mb-4">{{ session('error') }}</div>
@endif
<div wire:loading wire:target="fetchData" class="position-fixed top-0 start-0 w-100 h-100 bg-dark bg-opacity-50 text-white d-flex align-items-center justify-content-center" style="z-index: 1050;">
Loading...
</div>
<div class="row mb-4">
<div class="col-md-8">
<div class="input-group" style="width: 300px;">
<span class="input-group-text"><i class="bi bi-search"></i></span>
<input type="text" wire:model.debounce.1000ms="search" class="form-control" placeholder="Search">
</div>
</div>
</div>
<div class="mb-4">
<button wire:click="handleBatchDelete" class="btn btn-danger" {{ count($selectedRowKeys) === 0 ? 'disabled' : '' }}>
Delete All
</button>
<span class="ms-2">
{{ count($selectedRowKeys) > 0 ? "Selected " . count($selectedRowKeys) . " items" : '' }}
</span>
</div>
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead class="table-light">
<tr>
@foreach($columns as $column)
<th>{{ $column['title'] }}</th>
@endforeach
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($data as $record)
<tr>
@foreach($columns as $column)
<td>{{ $record[$column['dataIndex']] ?? '' }}</td>
@endforeach
<td>
@foreach($column['renderActions'] ?? [] as $action)
@if($action['action_name'] === 'delete')
<button wire:click="delete('{{ $action['path'] }}', {{ $record[$keyValue] }})" class="btn btn-danger btn-sm me-1">Delete</button>
@else
<button wire:click="redirect('{{ $action['action_name'] }}', '{{ $action['path'] }}', {{ $record[$keyValue] }})" class="btn btn-primary btn-sm me-1">{{ ucfirst($action['action_name']) }}</button>
@endif
@endforeach
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@if($total > 0)
<div class="d-flex justify-content-end mt-4">
<nav aria-label="Page navigation">
<ul class="pagination">
@for($i = 1; $i <= ceil($total / $perPage); $i++)
<li class="page-item {{ $currentPage === $i ? 'active' : '' }}">
<button wire:click="updatePage({{ $i }})" class="page-link">{{ $i }}</button>
</li>
@endfor
</ul>
</nav>
</div>
@endif
</div>