@props([ 'id' => null, 'title' => null, 'eyebrow' => null, 'description' => null, 'columns' => [], 'rows' => [], 'paginator' => null, 'createUrl' => null, 'createLabel' => 'New record', 'bulkDeleteUrl' => null, 'bulkDeleteLabel' => 'Delete selected', 'bulkDeleteConfirm' => 'Delete selected records?', 'emptyTitle' => 'No records found', 'emptyText' => 'Try adjusting filters or create a new record.', 'selectable' => true, 'settingsLabel' => 'Table settings', ]) @php $tableId = $id ?: 'erp-table-'.str()->random(8); $hasRowActions = collect($rows)->contains(fn ($row) => ! empty($row['actions'])); $previewDrawerId = $tableId.'_preview_drawer'; $hasPreviewActions = collect($rows)->contains(function ($row) { return collect($row['actions'] ?? [])->contains(fn ($action) => ! empty($action['preview'])); }); $columnCount = count($columns); $totalRows = $paginator ? $paginator->total() : count($rows); $defaultFootnote = $paginator && $totalRows > 0 ? 'Showing '.$paginator->firstItem().' - '.$paginator->lastItem().' of '.$totalRows : 'Showing '.count($rows).' of '.$totalRows; @endphp
@if ($eyebrow)

{{ $eyebrow }}

@endif @if ($title)

{{ $title }}

@endif @if ($description)

{{ $description }}

@endif
@isset($filters)
{{ $filters }}
@endisset
@if ($bulkDeleteUrl && $selectable) @endif @if ($createUrl) {{ $createLabel }} @endif
@if ($selectable)
@foreach ($rows as $row)
@endforeach
@endif
@foreach ($columns as $column) @php $key = $column['key']; @endphp @endforeach @forelse ($rows as $row) @foreach ($columns as $column) @php $key = $column['key']; $cell = $row['cells'][$key] ?? null; $cellArray = is_array($cell) ? $cell : ['value' => $cell]; $sortValue = $cellArray['sort'] ?? $cellArray['value'] ?? ''; $filterValue = $cellArray['filter'] ?? $cellArray['label'] ?? $cellArray['value'] ?? ''; @endphp @endforeach @empty @endforelse
@if (($column['sortable'] ?? true) === true) @else {{ $column['label'] }} @endif
@if (($column['filterable'] ?? true) !== false) @endif @if (($column['resizable'] ?? true) === true) @endif
{{ $emptyTitle }} {{ $emptyText }}
@if ($hasRowActions)
Row actions
@foreach ($rows as $row)
@endforeach
@endif
@if ($hasPreviewActions) @endif