@php
use Filament\Support\Enums\Alignment;
use Filament\Support\Facades\FilamentView;
use Filament\Tables\Enums\ActionsPosition;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Enums\RecordCheckboxPosition;
$actions = $getActions();
$actionsAlignment = $getActionsAlignment();
$actionsPosition = $getActionsPosition();
$actionsColumnLabel = $getActionsColumnLabel();
$columns = $getVisibleColumns();
$collapsibleColumnsLayout = $getCollapsibleColumnsLayout();
$content = $getContent();
$contentGrid = $getContentGrid();
$contentFooter = $getContentFooter();
$filterIndicators = [
...($hasSearch() ? ['resetTableSearch' => $getSearchIndicator()] : []),
...collect($getColumnSearchIndicators())
->mapWithKeys(fn (string $indicator, string $column): array => [
"resetTableColumnSearch('{$column}')" => $indicator,
])
->all(),
...array_reduce(
$getFilters(),
fn (array $carry, \Filament\Tables\Filters\BaseFilter $filter): array => [
...$carry,
...collect($filter->getIndicators())
->mapWithKeys(fn (string $label, int | string $field) => [
"removeTableFilter('{$filter->getName()}'" . (is_string($field) ? ' , \'' . $field . '\'' : null) . ')' => $label,
])
->all(),
],
[],
),
];
$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();
$isColumnSearchVisible = $isSearchableByColumn();
$isGlobalSearchVisible = $isSearchable();
$isSelectionEnabled = $isSelectionEnabled();
$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 || count($groups) || $isGlobalSearchVisible || $hasFilters || count($filterIndicators) || $hasColumnToggleDropdown;
$hasHeaderToolbar = $isReorderable || count($groups) || $isGlobalSearchVisible || $hasFiltersDialog || $hasColumnToggleDropdown;
$pluralModelLabel = $getPluralModelLabel();
$records = $isLoaded ? $getRecords() : null;
$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 (Filament\Tables\Columns\Column $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 ($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' => $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 md:pe-3' => (! $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),
'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 ($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)
{{ $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\LengthAwarePaginator)) || $records->total()))
@endif
@if ($hasFiltersBelowContent)
@endif