@php use Filament\Support\Enums\Alignment; use Filament\Support\Enums\VerticalAlignment; use Filament\Support\Facades\FilamentView; use Filament\Tables\Columns\Column; use Filament\Tables\Columns\ColumnGroup; use Filament\Tables\Enums\ActionsPosition; use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Enums\RecordCheckboxPosition; use Illuminate\Support\Str; $actions = $getActions(); $actionsAlignment = $getActionsAlignment(); $actionsPosition = $getActionsPosition(); $actionsColumnLabel = $getActionsColumnLabel(); $activeFiltersCount = $getActiveFiltersCount(); $columns = $getVisibleColumns(); $collapsibleColumnsLayout = $getCollapsibleColumnsLayout(); $columnsLayout = $getColumnsLayout(); $content = $getContent(); $contentGrid = $getContentGrid(); $contentFooter = $getContentFooter(); $filterIndicators = $getFilterIndicators(); $hasColumnGroups = $hasColumnGroups(); $hasColumnsLayout = $hasColumnsLayout(); $hasSummary = $hasSummary(); $header = $getHeader(); $headerActions = array_filter( $getHeaderActions(), fn (\Filament\Tables\Actions\Action | \Filament\Tables\Actions\BulkAction | \Filament\Tables\Actions\ActionGroup $action): bool => $action->isVisible(), ); $headerActionsPosition = $getHeaderActionsPosition(); $heading = $getHeading(); $group = $getGrouping(); $bulkActions = array_filter( $getBulkActions(), fn (\Filament\Tables\Actions\BulkAction | \Filament\Tables\Actions\ActionGroup $action): bool => $action->isVisible(), ); $groups = $getGroups(); $description = $getDescription(); $isGroupsOnly = $isGroupsOnly() && $group; $isReorderable = $isReorderable(); $isReordering = $isReordering(); $areGroupingSettingsVisible = (! $isReordering) && count($groups) && (! $areGroupingSettingsHidden()); $isColumnSearchVisible = $isSearchableByColumn(); $isGlobalSearchVisible = $isSearchable(); $isSearchOnBlur = $isSearchOnBlur(); $isSelectionEnabled = $isSelectionEnabled() && (! $isGroupsOnly); $recordCheckboxPosition = $getRecordCheckboxPosition(); $isStriped = $isStriped(); $isLoaded = $isLoaded(); $hasFilters = $isFilterable(); $filtersLayout = $getFiltersLayout(); $filtersTriggerAction = $getFiltersTriggerAction(); $hasFiltersDialog = $hasFilters && in_array($filtersLayout, [FiltersLayout::Dropdown, FiltersLayout::Modal]); $hasFiltersAboveContent = $hasFilters && in_array($filtersLayout, [FiltersLayout::AboveContent, FiltersLayout::AboveContentCollapsible]); $hasFiltersAboveContentCollapsible = $hasFilters && ($filtersLayout === FiltersLayout::AboveContentCollapsible); $hasFiltersBelowContent = $hasFilters && ($filtersLayout === FiltersLayout::BelowContent); $hasColumnToggleDropdown = $hasToggleableColumns(); $hasHeader = $header || $heading || $description || ($headerActions && (! $isReordering)) || $isReorderable || $areGroupingSettingsVisible || $isGlobalSearchVisible || $hasFilters || count($filterIndicators) || $hasColumnToggleDropdown; $hasHeaderToolbar = $isReorderable || $areGroupingSettingsVisible || $isGlobalSearchVisible || $hasFiltersDialog || $hasColumnToggleDropdown; $pluralModelLabel = $getPluralModelLabel(); $records = $isLoaded ? $getRecords() : null; $searchDebounce = $getSearchDebounce(); $allSelectableRecordsCount = ($isSelectionEnabled && $isLoaded) ? $getAllSelectableRecordsCount() : null; $columnsCount = count($columns); $reorderRecordsTriggerAction = $getReorderRecordsTriggerAction($isReordering); $toggleColumnsTriggerAction = $getToggleColumnsTriggerAction(); if (count($actions) && (! $isReordering)) { $columnsCount++; } if ($isSelectionEnabled || $isReordering) { $columnsCount++; } if ($group) { $groupedSummarySelectedState = $this->getTableSummarySelectedState($this->getAllTableSummaryQuery(), modifyQueryUsing: fn (\Illuminate\Database\Query\Builder $query) => $group->groupQuery($query, model: $getQuery()->getModel())); } $getHiddenClasses = function (Column | ColumnGroup $column): ?string { if ($breakpoint = $column->getHiddenFrom()) { return match ($breakpoint) { 'sm' => 'sm:hidden', 'md' => 'md:hidden', 'lg' => 'lg:hidden', 'xl' => 'xl:hidden', '2xl' => '2xl:hidden', }; } if ($breakpoint = $column->getVisibleFrom()) { return match ($breakpoint) { 'sm' => 'hidden sm:table-cell', 'md' => 'hidden md:table-cell', 'lg' => 'hidden lg:table-cell', 'xl' => 'hidden xl:table-cell', '2xl' => 'hidden 2xl:table-cell', }; } return null; }; @endphp
$records === null, ]) >
@if ($header) {{ $header }} @elseif (($heading || $description || $headerActions) && ! $isReordering) @endif @if ($hasFiltersAboveContent)
@if ($hasFiltersAboveContentCollapsible) {{ $filtersTriggerAction->badge($activeFiltersCount) }} @endif
@endif
{{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_START, scopes: static::class) }}
{{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_REORDER_TRIGGER_BEFORE, scopes: static::class) }} @if ($isReorderable) {{ $reorderRecordsTriggerAction }} @endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_REORDER_TRIGGER_AFTER, scopes: static::class) }} @if ((! $isReordering) && count($bulkActions)) @endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_GROUPING_SELECTOR_BEFORE, scopes: static::class) }} @if ($areGroupingSettingsVisible) @endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_GROUPING_SELECTOR_AFTER, scopes: static::class) }}
@if ($isGlobalSearchVisible || $hasFiltersDialog || $hasColumnToggleDropdown)
{{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_SEARCH_BEFORE, scopes: static::class) }} @if ($isGlobalSearchVisible) @endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_SEARCH_AFTER, scopes: static::class) }} @if ($hasFiltersDialog || $hasColumnToggleDropdown) @if ($hasFiltersDialog) @endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_TOGGLE_COLUMN_TRIGGER_BEFORE, scopes: static::class) }} @if ($hasColumnToggleDropdown) @endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_TOGGLE_COLUMN_TRIGGER_AFTER, scopes: static::class) }} @endif
@endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_END) }}
@if ($isReordering) @elseif ($isSelectionEnabled && $isLoaded) @endif @if (count($filterIndicators)) @endif
! $hasHeader, ]) > @if (($content || $hasColumnsLayout) && ($records !== null) && count($records)) @if (! $isReordering) @php $sortableColumns = array_filter( $columns, fn (\Filament\Tables\Columns\Column $column): bool => $column->isSortable(), ); @endphp @if ($isSelectionEnabled || count($sortableColumns))
@if ($isSelectionEnabled && (! $isReordering)) @endif @if (count($sortableColumns))
@endif
@endif @endif @if ($content) {{ $content->with(['records' => $records]) }} @else $contentGrid, 'pt-0' => $contentGrid && $this->getTableGrouping(), 'gap-y-px bg-gray-200 dark:bg-white/5' => ! $contentGrid, ]) > @php $previousRecord = null; $previousRecordGroupKey = null; $previousRecordGroupTitle = null; @endphp @foreach ($records as $record) @php $recordAction = $getRecordAction($record); $recordKey = $getRecordKey($record); $recordUrl = $getRecordUrl($record); $recordGroupKey = $group?->getStringKey($record); $recordGroupTitle = $group?->getTitle($record); $collapsibleColumnsLayout?->record($record); $hasCollapsibleColumnsLayout = (bool) $collapsibleColumnsLayout?->isVisible(); @endphp @if ($recordGroupTitle !== $previousRecordGroupTitle) @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle)) @endif $contentGrid, ]) :x-bind:class="$hasSummary ? null : '{ \'-mb-4 border-b-0\': isGroupCollapsed(\'' . $recordGroupTitle . '\') }'" > @if ($isSelectionEnabled)
@endif
@endif
($recordUrl || $recordAction) && (! $contentGrid), 'hover:bg-gray-50 dark:hover:bg-white/10 dark:hover:ring-white/20' => ($recordUrl || $recordAction) && $contentGrid, 'rounded-xl shadow-sm ring-1 ring-gray-950/5 dark:bg-white/5 dark:ring-white/10' => $contentGrid, ...$getRecordClasses($record), ]) x-bind:class="{ 'hidden': {{ $group?->isCollapsible() ? 'true' : 'false' }} && isGroupCollapsed('{{ $recordGroupTitle }}'), {{ ($contentGrid ? '\'bg-gray-50 dark:bg-white/10 dark:ring-white/20\'' : '\'bg-gray-50 dark:bg-white/5 before:absolute before:start-0 before:inset-y-0 before:w-0.5 before:bg-primary-600 dark:before:bg-primary-500\'') . ': isRecordSelected(\'' . $recordKey . '\')' }}, {{ $contentGrid ? '\'bg-white dark:bg-white/5 dark:ring-white/10\': ! isRecordSelected(\'' . $recordKey . '\')' : '\'\':\'\'' }}, }" > @php $hasItemBeforeRecordContent = $isReordering || ($isSelectionEnabled && $isRecordSelectable($record)); $isRecordCollapsible = $hasCollapsibleColumnsLayout && (! $isReordering); $hasItemAfterRecordContent = $isRecordCollapsible; $recordHasActions = count($actions) && (! $isReordering); $recordContentHorizontalPaddingClasses = \Illuminate\Support\Arr::toCssClasses([ 'ps-3' => (! $contentGrid) && $hasItemBeforeRecordContent, 'ps-4 sm:ps-6' => (! $contentGrid) && (! $hasItemBeforeRecordContent), 'pe-3' => (! $contentGrid) && $hasItemAfterRecordContent, 'pe-4 sm:pe-6' => (! $contentGrid) && (! $hasItemAfterRecordContent), 'ps-2' => $contentGrid && $hasItemBeforeRecordContent, 'ps-4' => $contentGrid && (! $hasItemBeforeRecordContent), 'pe-2' => $contentGrid && $hasItemAfterRecordContent, 'pe-4' => $contentGrid && (! $hasItemAfterRecordContent), ]); $recordActionsClasses = \Illuminate\Support\Arr::toCssClasses([ 'md:ps-3' => (! $contentGrid), 'order-first' => $actionsPosition === ActionsPosition::BeforeColumns, 'ps-3' => (! $contentGrid) && $hasItemBeforeRecordContent, 'ps-4 sm:ps-6' => (! $contentGrid) && (! $hasItemBeforeRecordContent), 'pe-3' => (! $contentGrid) && $hasItemAfterRecordContent, 'pe-4 sm:pe-6' => (! $contentGrid) && (! $hasItemAfterRecordContent), 'ps-2' => $contentGrid && $hasItemBeforeRecordContent, 'ps-4' => $contentGrid && (! $hasItemBeforeRecordContent), 'pe-2' => $contentGrid && $hasItemAfterRecordContent, 'pe-4' => $contentGrid && (! $hasItemAfterRecordContent), ]); @endphp
(! $contentGrid) && $hasItemBeforeRecordContent, 'pe-1 sm:pe-3' => (! $contentGrid) && $hasItemAfterRecordContent, 'ps-1' => $contentGrid && $hasItemBeforeRecordContent, 'pe-1' => $contentGrid && $hasItemAfterRecordContent, ]) > @if ($isReordering) @elseif ($isSelectionEnabled && $isRecordSelectable($record)) @endif @php $recordContentClasses = \Illuminate\Support\Arr::toCssClasses([ $recordContentHorizontalPaddingClasses, 'block w-full', ]); @endphp
! $contentGrid, ]) >
@if ($recordUrl) @elseif ($recordAction) @php $recordWireClickAction = $getAction($recordAction) ? "mountTableAction('{$recordAction}', '{$recordKey}')" : $recordWireClickAction = "{$recordAction}('{$recordKey}')"; @endphp @else
@endif @if ($hasCollapsibleColumnsLayout && (! $isReordering))
{{ $collapsibleColumnsLayout->viewData(['recordKey' => $recordKey]) }}
@endif
@if ($recordHasActions) @endif
@if ($isRecordCollapsible) @endif
@php $previousRecordGroupKey = $recordGroupKey; $previousRecordGroupTitle = $recordGroupTitle; $previousRecord = $record; @endphp @endforeach @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle) && ((! $records instanceof \Illuminate\Contracts\Pagination\Paginator) || (! $records->hasMorePages()))) @endif
@endif @if (($content || $hasColumnsLayout) && $contentFooter) {{ $contentFooter->with([ 'columns' => $columns, 'records' => $records, ]) }} @endif @if ($hasSummary && (! $isReordering)) @endif @elseif (($records !== null) && count($records)) @if ($hasColumnGroups) @if ($isReordering) @else @if (count($actions) && in_array($actionsPosition, [ActionsPosition::BeforeCells, ActionsPosition::BeforeColumns])) @endif @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) @endif @endif @foreach ($columnsLayout as $columnGroup) @if ($columnGroup instanceof Column) @if ($columnGroup->isVisible() && (! $columnGroup->isToggledHidden())) @endif @elseif ($columnGroup instanceof ColumnGroup) @php $columnGroupAlignment = $columnGroup->getAlignment(); $columnGroupColumnsCount = count($columnGroup->getVisibleColumns()); $isColumnGroupHeaderWrapped = $columnGroup->isHeaderWrapped(); @endphp @if ($columnGroupColumnsCount) getExtraHeaderAttributeBag()->class([ 'fi-table-header-group-cell border-gray-200 px-3 py-2 dark:border-white/5 sm:first-of-type:ps-6 sm:last-of-type:pe-6 [&:not(:first-of-type)]:border-s [&:not(:last-of-type)]:border-e', ]) }} >
! $isColumnGroupHeaderWrapped, 'whitespace-normal' => $isColumnGroupHeaderWrapped, match ($columnGroupAlignment) { Alignment::Start => 'justify-start', Alignment::Center => 'justify-center', Alignment::End => 'justify-end', Alignment::Left => 'justify-start rtl:flex-row-reverse', Alignment::Right => 'justify-end rtl:flex-row-reverse', Alignment::Justify, Alignment::Between => 'justify-between', default => $columnGroupAlignment, }, $getHiddenClasses($columnGroup), ]) > {{ $columnGroup->getLabel() }}
@endif @endif @endforeach @if (! $isReordering) @if (count($actions) && in_array($actionsPosition, [ActionsPosition::AfterColumns, ActionsPosition::AfterCells])) @endif @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells) @endif @endif
@endif @if ($isReordering) @else @if (count($actions) && $actionsPosition === ActionsPosition::BeforeCells) @if ($actionsColumnLabel) {{ $actionsColumnLabel }} @else @endif @endif @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) @endif @if (count($actions) && $actionsPosition === ActionsPosition::BeforeColumns) @if ($actionsColumnLabel) {{ $actionsColumnLabel }} @else @endif @endif @endif @foreach ($columns as $column) @php $columnWidth = $column->getWidth(); @endphp {{ $column->getLabel() }} @endforeach @if (! $isReordering) @if (count($actions) && $actionsPosition === ActionsPosition::AfterColumns) @if ($actionsColumnLabel) {{ $actionsColumnLabel }} @else @endif @endif @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells) @endif @if (count($actions) && $actionsPosition === ActionsPosition::AfterCells) @if ($actionsColumnLabel) {{ $actionsColumnLabel }} @else @endif @endif @endif @if ($isColumnSearchVisible) @if ($isReordering) @else @if (count($actions) && in_array($actionsPosition, [ActionsPosition::BeforeCells, ActionsPosition::BeforeColumns])) @endif @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) @endif @endif @foreach ($columns as $column) getName())->camel()->kebab(), 'px-3 py-2', ]) > @if ($column->isIndividuallySearchable()) @endif @endforeach @if (! $isReordering) @if (count($actions) && in_array($actionsPosition, [ActionsPosition::AfterColumns, ActionsPosition::AfterCells])) @endif @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells) @endif @endif @endif @if (($records !== null) && count($records)) @php $isRecordRowStriped = false; $previousRecord = null; $previousRecordGroupKey = null; $previousRecordGroupTitle = null; @endphp @foreach ($records as $record) @php $recordAction = $getRecordAction($record); $recordKey = $getRecordKey($record); $recordUrl = $getRecordUrl($record); $recordGroupKey = $group?->getStringKey($record); $recordGroupTitle = $group?->getTitle($record); @endphp @if ($recordGroupTitle !== $previousRecordGroupTitle) @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle)) @endif @if (! $isGroupsOnly) @php $groupHeaderColspan = $columnsCount; if ($isSelectionEnabled) { $groupHeaderColspan--; if ( ($recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) && count($actions) && ($actionsPosition === ActionsPosition::BeforeCells) ) { $groupHeaderColspan--; } } @endphp @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) @if (count($actions) && $actionsPosition === ActionsPosition::BeforeCells) @endif @endif @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells) @endif @endif @php $isRecordRowStriped = false; @endphp @endif @if (! $isGroupsOnly) $isReordering, ...$getRecordClasses($record), ]) > @if ($isReordering) @endif @if (count($actions) && $actionsPosition === ActionsPosition::BeforeCells && (! $isReordering)) @endif @if ($isSelectionEnabled && ($recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) && (! $isReordering)) @if ($isRecordSelectable($record)) @endif @endif @if (count($actions) && $actionsPosition === ActionsPosition::BeforeColumns && (! $isReordering)) @endif @foreach ($columns as $column) @php $column->record($record); $column->rowLoop($loop->parent); @endphp @endforeach @if (count($actions) && $actionsPosition === ActionsPosition::AfterColumns && (! $isReordering)) @endif @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells && (! $isReordering)) @if ($isRecordSelectable($record)) @endif @endif @if (count($actions) && $actionsPosition === ActionsPosition::AfterCells) $isReordering, ]) > @endif @endif @php $isRecordRowStriped = ! $isRecordRowStriped; $previousRecord = $record; $previousRecordGroupKey = $recordGroupKey; $previousRecordGroupTitle = $recordGroupTitle; @endphp @endforeach @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle) && ((! $records instanceof \Illuminate\Contracts\Pagination\Paginator) || (! $records->hasMorePages()))) @endif @if ($hasSummary && (! $isReordering)) @endif @if ($contentFooter) {{ $contentFooter->with([ 'columns' => $columns, 'records' => $records, ]) }} @endif @endif
@elseif ($records === null)
@elseif ($emptyState = $getEmptyState()) {{ $emptyState }} @else @endif
@if ((($records instanceof \Illuminate\Contracts\Pagination\Paginator) || ($records instanceof \Illuminate\Contracts\Pagination\CursorPaginator)) && ((! ($records instanceof \Illuminate\Contracts\Pagination\LengthAwarePaginator)) || $records->total())) @endif @if ($hasFiltersBelowContent) @endif