- @if($this->isCardViewEnabled())
+ @if($this->isCardViewEnabled() && ! $this->isCardOnly())
@include('query-builder::components.view-toggle')
@endif
diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php
index ae29214..e733284 100644
--- a/resources/views/table.blade.php
+++ b/resources/views/table.blade.php
@@ -8,7 +8,7 @@
@if($this->isSearchVisible() && $this->searchableColumnsSet() && ! $this->areActionsVisible())
@if($this->isFiltered() || $this->isSearchActive() || $this->rows->count() > 0)
- @if($this->isCardViewEnabled())
+ @if($this->isCardViewEnabled() && ! $this->isCardOnly())
@include('query-builder::components.view-toggle')
@endif
diff --git a/src/Support/Concerns/WithCardView.php b/src/Support/Concerns/WithCardView.php
index bc79ea8..da57002 100644
--- a/src/Support/Concerns/WithCardView.php
+++ b/src/Support/Concerns/WithCardView.php
@@ -13,6 +13,18 @@ public function cardLayout(): ?CardLayout
return null;
}
+ public function isCardOnly(): bool
+ {
+ return false;
+ }
+
+ public function mountWithCardView(): void
+ {
+ if ($this->isCardOnly() && $this->isCardViewEnabled()) {
+ $this->viewMode = 'cards';
+ }
+ }
+
public function toggleViewMode(): void
{
$this->viewMode = $this->viewMode === 'table' ? 'cards' : 'table';