diff --git a/src/Traits/Styling/Configuration/ActionsStylingConfiguration.php b/src/Traits/Styling/Configuration/ActionsStylingConfiguration.php
deleted file mode 100644
index 51b3a3f99..000000000
--- a/src/Traits/Styling/Configuration/ActionsStylingConfiguration.php
+++ /dev/null
@@ -1,13 +0,0 @@
-actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes];
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php
deleted file mode 100644
index 6f74ed5a3..000000000
--- a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php
+++ /dev/null
@@ -1,86 +0,0 @@
-setCustomAttributes('bulkActionsButtonAttributes', $bulkActionsButtonAttributes);
-
- return $this;
- }
-
- /**
- * Used to set attributes for the Bulk Actions Menu
- */
- public function setBulkActionsMenuAttributes(array $bulkActionsMenuAttributes): self
- {
- $this->setCustomAttributes('bulkActionsMenuAttributes', $bulkActionsMenuAttributes);
-
- return $this;
- }
-
- /**
- * Used to set attributes for the Bulk Actions Menu Items
- */
- public function setBulkActionsMenuItemAttributes(array $bulkActionsMenuItemAttributes): self
- {
- $this->setCustomAttributes('bulkActionsMenuItemAttributes', $bulkActionsMenuItemAttributes);
-
- return $this;
- }
-
- /**
- * Used to set attributes for the Bulk Actions TD in the Row
- */
- public function setBulkActionsTdAttributes(array $bulkActionsTdAttributes): self
- {
- $this->setCustomAttributes('bulkActionsTdAttributes', $bulkActionsTdAttributes);
-
- return $this;
- }
-
- /**
- * Used to set attributes for the Bulk Actions Checkbox in the Row
- */
- public function setBulkActionsTdCheckboxAttributes(array $bulkActionsTdCheckboxAttributes): self
- {
- $this->setCustomAttributes('bulkActionsTdCheckboxAttributes', $bulkActionsTdCheckboxAttributes);
-
- return $this;
- }
-
- /**
- * Used to set attributes for the
for Bulk Actions
- */
- public function setBulkActionsThAttributes(array $bulkActionsThAttributes): self
- {
- $this->setCustomAttributes('bulkActionsThAttributes', $bulkActionsThAttributes);
-
- return $this;
- }
-
- /**
- * Used to set attributes for the Bulk Actions Checkbox in the |
- */
- public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxAttributes): self
- {
- $this->setCustomAttributes('bulkActionsThCheckboxAttributes', $bulkActionsThCheckboxAttributes);
-
- return $this;
- }
-
- /**
- * Used to set attributes for the Bulk Actions Row Buttons
- */
- public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self
- {
- $this->setCustomAttributes('bulkActionsRowButtonAttributes', $bulkActionsRowButtonAttributes);
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/ColumnSelectStylingConfiguration.php b/src/Traits/Styling/Configuration/ColumnSelectStylingConfiguration.php
deleted file mode 100644
index 242d48d57..000000000
--- a/src/Traits/Styling/Configuration/ColumnSelectStylingConfiguration.php
+++ /dev/null
@@ -1,20 +0,0 @@
-columnSelectButtonAttributes = [...$this->columnSelectButtonAttributes, ...$attributes];
-
- return $this;
- }
-
- public function setColumnSelectMenuOptionCheckboxAttributes(array $attributes = []): self
- {
- $this->columnSelectMenuOptionCheckboxAttributes = [...$this->columnSelectMenuOptionCheckboxAttributes, ...$attributes];
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/FooterStylingConfiguration.php b/src/Traits/Styling/Configuration/FooterStylingConfiguration.php
deleted file mode 100644
index cd1348520..000000000
--- a/src/Traits/Styling/Configuration/FooterStylingConfiguration.php
+++ /dev/null
@@ -1,22 +0,0 @@
-footerTrAttributesCallback = $callback;
-
- return $this;
- }
-
- public function setFooterTdAttributes(Closure $callback): self
- {
- $this->footerTdAttributesCallback = $callback;
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php
deleted file mode 100644
index c07780bdc..000000000
--- a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php
+++ /dev/null
@@ -1,34 +0,0 @@
-setCustomAttributes('loadingPlaceHolderAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: false, classicMode: true), ...$attributes]);
-
- return $this;
- }
-
- public function setLoadingPlaceHolderIconAttributes(array $attributes): self
- {
- $this->setCustomAttributes('loadingPlaceHolderIconAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: false, classicMode: true), ...$attributes]);
-
- return $this;
- }
-
- public function setLoadingPlaceHolderRowAttributes(array $attributes): self
- {
- $this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]);
-
- return $this;
- }
-
- public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self
- {
- $this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]);
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/PaginationStylingConfiguration.php b/src/Traits/Styling/Configuration/PaginationStylingConfiguration.php
deleted file mode 100644
index 20b3cb898..000000000
--- a/src/Traits/Styling/Configuration/PaginationStylingConfiguration.php
+++ /dev/null
@@ -1,20 +0,0 @@
-perPageFieldAttributes = [...$this->perPageFieldAttributes, ...$attributes];
-
- return $this;
- }
-
- public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self
- {
- $this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes);
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/ReorderStylingConfiguration.php b/src/Traits/Styling/Configuration/ReorderStylingConfiguration.php
deleted file mode 100644
index 893d249b4..000000000
--- a/src/Traits/Styling/Configuration/ReorderStylingConfiguration.php
+++ /dev/null
@@ -1,16 +0,0 @@
- for Reorder Column
- */
- public function setReorderThAttributes(array $reorderThAttributes): self
- {
- $this->reorderThAttributes = [...$this->reorderThAttributes, ...$reorderThAttributes];
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/SecondaryHeaderStylingConfiguration.php b/src/Traits/Styling/Configuration/SecondaryHeaderStylingConfiguration.php
deleted file mode 100644
index b01c1d008..000000000
--- a/src/Traits/Styling/Configuration/SecondaryHeaderStylingConfiguration.php
+++ /dev/null
@@ -1,22 +0,0 @@
-secondaryHeaderTrAttributesCallback = $callback;
-
- return $this;
- }
-
- public function setSecondaryHeaderTdAttributes(Closure $callback): self
- {
- $this->secondaryHeaderTdAttributesCallback = $callback;
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/SortingPillsStylingConfiguration.php b/src/Traits/Styling/Configuration/SortingPillsStylingConfiguration.php
deleted file mode 100644
index 846a7a11e..000000000
--- a/src/Traits/Styling/Configuration/SortingPillsStylingConfiguration.php
+++ /dev/null
@@ -1,27 +0,0 @@
-sortingPillsItemAttributes = [...$this->sortingPillsItemAttributes, ...$attributes];
-
- return $this;
- }
-
- public function setSortingPillsClearSortButtonAttributes(array $attributes = []): self
- {
- $this->sortingPillsClearSortButtonAttributes = [...$this->sortingPillsClearSortButtonAttributes, ...$attributes];
-
- return $this;
- }
-
- public function setSortingPillsClearAllButtonAttributes(array $attributes = []): self
- {
- $this->sortingPillsClearAllButtonAttributes = [...$this->sortingPillsClearAllButtonAttributes, ...$attributes];
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/Configuration/ToolsStylingConfiguration.php b/src/Traits/Styling/Configuration/ToolsStylingConfiguration.php
deleted file mode 100644
index 9b2ca17f4..000000000
--- a/src/Traits/Styling/Configuration/ToolsStylingConfiguration.php
+++ /dev/null
@@ -1,20 +0,0 @@
-setCustomAttributes(propertyName: 'toolsAttributes', customAttributes: $toolsAttributes);
-
- return $this;
- }
-
- public function setToolBarAttributes(array $toolBarAttributes = []): self
- {
- $this->setCustomAttributes(propertyName: 'toolBarAttributes', customAttributes: $toolBarAttributes);
-
- return $this;
- }
-}
diff --git a/src/Traits/Styling/HasActionsStyling.php b/src/Traits/Styling/HasActionsStyling.php
index 9e32c1dac..5e66b2cb3 100644
--- a/src/Traits/Styling/HasActionsStyling.php
+++ b/src/Traits/Styling/HasActionsStyling.php
@@ -2,13 +2,22 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\ActionsStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\ActionsStylingHelpers;
+use Livewire\Attributes\Computed;
trait HasActionsStyling
{
- use ActionsStylingConfiguration,
- ActionsStylingHelpers;
-
protected array $actionWrapperAttributes = ['class' => '', 'default-styling' => true, 'default-colors' => true];
+
+ #[Computed]
+ public function getActionWrapperAttributes(): array
+ {
+ return [...['class' => '', 'default-styling' => true, 'default-colors' => true], ...$this->actionWrapperAttributes];
+ }
+
+ public function setActionWrapperAttributes(array $actionWrapperAttributes): self
+ {
+ $this->actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes];
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasBulkActionsStyling.php b/src/Traits/Styling/HasBulkActionsStyling.php
index 07bf1f133..5f4638455 100644
--- a/src/Traits/Styling/HasBulkActionsStyling.php
+++ b/src/Traits/Styling/HasBulkActionsStyling.php
@@ -2,14 +2,11 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\BulkActionStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\BulkActionStylingHelpers;
+use Illuminate\View\ComponentAttributeBag;
+use Livewire\Attributes\Computed;
trait HasBulkActionsStyling
{
- use BulkActionStylingConfiguration,
- BulkActionStylingHelpers;
-
protected array $bulkActionsCheckboxAttributes = [];
protected array $bulkActionsThAttributes = ['default' => true];
@@ -27,4 +24,190 @@ trait HasBulkActionsStyling
protected array $bulkActionsMenuItemAttributes = ['default-colors' => true, 'default-styling' => true];
protected array $bulkActionsRowButtonAttributes = ['default-colors' => true, 'default-styling' => true];
+
+ /**
+ * Used to get attributes for the Bulk Actions Button
+ *
+ * @return array
+ */
+ #[Computed]
+ public function getBulkActionsButtonAttributes(): array
+ {
+ return $this->getCustomAttributes('bulkActionsButtonAttributes', true);
+
+ }
+
+ /**
+ * Used to get attributes for the Bulk Actions Menu (Dropdown)
+ *
+ * @return array
+ */
+ #[Computed]
+ public function getBulkActionsMenuAttributes(): array
+ {
+ return $this->getCustomAttributes('bulkActionsMenuAttributes', true, false);
+
+ }
+
+ /**
+ * Used to get attributes for the items in the Bulk Actions Menu (Dropdown)
+ *
+ * @return array
+ */
+ #[Computed]
+ public function getBulkActionsMenuItemAttributes(): array
+ {
+ return $this->getCustomAttributes('bulkActionsMenuItemAttributes', true, false);
+
+ }
+
+ /**
+ * Used to get attributes for the for Bulk Actions
+ *
+ * @return array
+ */
+ #[Computed]
+ public function getBulkActionsThAttributes(): array
+ {
+ return $this->getCustomAttributes('bulkActionsThAttributes');
+
+ }
+
+ /**
+ * Used to check if the Bulk Actions TH has any attributes (supports historic approach)
+ */
+ #[Computed]
+ public function hasBulkActionsThAttributes(): bool
+ {
+ return $this->getBulkActionsThAttributes() != ['default' => true, 'default-colors' => false, 'default-styling' => false];
+ }
+
+ /**
+ * Used to get attributes for the Checkbox for Bulk Actions TH
+ *
+ * @return array
+ */
+ public function getBulkActionsThCheckboxAttributes(): array
+ {
+ return $this->getCustomAttributes('bulkActionsThCheckboxAttributes');
+ }
+
+ /**
+ * Used to get attributes for the Bulk Actions TD
+ *
+ * @return array
+ */
+ public function getBulkActionsTdAttributes(): array
+ {
+ return $this->getCustomAttributes('bulkActionsTdAttributes');
+ }
+
+ /**
+ * Used to get attributes for the Bulk Actions TD
+ *
+ * @return array
+ */
+ public function getBulkActionsTdCheckboxAttributes(): array
+ {
+ return $this->getCustomAttributes('bulkActionsTdCheckboxAttributes');
+
+ }
+
+ /**
+ * Used to get attributes for the Bulk Actions Row Buttons
+ *
+ * @return array
+ */
+ #[Computed]
+ public function getBulkActionsRowButtonAttributes(): array
+ {
+ return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true);
+
+ }
+
+ #[Computed]
+ public function getBulkActionsRowButtonAttributesBag(): ComponentAttributeBag
+ {
+ return $this->getCustomAttributesBagFromArray($this->getBulkActionsRowButtonAttributes());
+ }
+
+ /**
+ * Used to set attributes for the Bulk Actions Menu Button
+ */
+ public function setBulkActionsButtonAttributes(array $bulkActionsButtonAttributes): self
+ {
+ $this->setCustomAttributes('bulkActionsButtonAttributes', $bulkActionsButtonAttributes);
+
+ return $this;
+ }
+
+ /**
+ * Used to set attributes for the Bulk Actions Menu
+ */
+ public function setBulkActionsMenuAttributes(array $bulkActionsMenuAttributes): self
+ {
+ $this->setCustomAttributes('bulkActionsMenuAttributes', $bulkActionsMenuAttributes);
+
+ return $this;
+ }
+
+ /**
+ * Used to set attributes for the Bulk Actions Menu Items
+ */
+ public function setBulkActionsMenuItemAttributes(array $bulkActionsMenuItemAttributes): self
+ {
+ $this->setCustomAttributes('bulkActionsMenuItemAttributes', $bulkActionsMenuItemAttributes);
+
+ return $this;
+ }
+
+ /**
+ * Used to set attributes for the Bulk Actions TD in the Row
+ */
+ public function setBulkActionsTdAttributes(array $bulkActionsTdAttributes): self
+ {
+ $this->setCustomAttributes('bulkActionsTdAttributes', $bulkActionsTdAttributes);
+
+ return $this;
+ }
+
+ /**
+ * Used to set attributes for the Bulk Actions Checkbox in the Row
+ */
+ public function setBulkActionsTdCheckboxAttributes(array $bulkActionsTdCheckboxAttributes): self
+ {
+ $this->setCustomAttributes('bulkActionsTdCheckboxAttributes', $bulkActionsTdCheckboxAttributes);
+
+ return $this;
+ }
+
+ /**
+ * Used to set attributes for the for Bulk Actions
+ */
+ public function setBulkActionsThAttributes(array $bulkActionsThAttributes): self
+ {
+ $this->setCustomAttributes('bulkActionsThAttributes', $bulkActionsThAttributes);
+
+ return $this;
+ }
+
+ /**
+ * Used to set attributes for the Bulk Actions Checkbox in the |
+ */
+ public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxAttributes): self
+ {
+ $this->setCustomAttributes('bulkActionsThCheckboxAttributes', $bulkActionsThCheckboxAttributes);
+
+ return $this;
+ }
+
+ /**
+ * Used to set attributes for the Bulk Actions Row Buttons
+ */
+ public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self
+ {
+ $this->setCustomAttributes('bulkActionsRowButtonAttributes', $bulkActionsRowButtonAttributes);
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasColumnSelectStyling.php b/src/Traits/Styling/HasColumnSelectStyling.php
index 9362c44d5..b1aea7eb9 100644
--- a/src/Traits/Styling/HasColumnSelectStyling.php
+++ b/src/Traits/Styling/HasColumnSelectStyling.php
@@ -2,15 +2,38 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\ColumnSelectStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\ColumnSelectStylingHelpers;
+use Illuminate\View\ComponentAttributeBag;
+use Livewire\Attributes\Computed;
trait HasColumnSelectStyling
{
- use ColumnSelectStylingConfiguration,
- ColumnSelectStylingHelpers;
-
protected array $columnSelectButtonAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => ''];
protected array $columnSelectMenuOptionCheckboxAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => ''];
+
+ #[Computed]
+ public function getColumnSelectButtonAttributes(): array
+ {
+ return $this->columnSelectButtonAttributes;
+ }
+
+ #[Computed]
+ public function getColumnSelectMenuOptionCheckboxAttributes(): array
+ {
+ return $this->columnSelectMenuOptionCheckboxAttributes;
+ }
+
+ public function setColumnSelectButtonAttributes(array $attributes = []): self
+ {
+ $this->columnSelectButtonAttributes = [...$this->columnSelectButtonAttributes, ...$attributes];
+
+ return $this;
+ }
+
+ public function setColumnSelectMenuOptionCheckboxAttributes(array $attributes = []): self
+ {
+ $this->columnSelectMenuOptionCheckboxAttributes = [...$this->columnSelectMenuOptionCheckboxAttributes, ...$attributes];
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasFooterStyling.php b/src/Traits/Styling/HasFooterStyling.php
index 1ef3dc394..abe4bd928 100644
--- a/src/Traits/Styling/HasFooterStyling.php
+++ b/src/Traits/Styling/HasFooterStyling.php
@@ -3,15 +3,43 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
use Closure;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\FooterStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\FooterStylingHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Column;
trait HasFooterStyling
{
- use FooterStylingConfiguration,
- FooterStylingHelpers;
-
protected ?Closure $footerTrAttributesCallback;
protected ?Closure $footerTdAttributesCallback;
+
+ /**
+ * @param mixed $rows
+ * @return array
+ */
+ public function getFooterTrAttributes($rows): array
+ {
+ return isset($this->footerTrAttributesCallback) ? call_user_func($this->footerTrAttributesCallback, $rows) : ['default' => true];
+ }
+
+ /**
+ * @param mixed $rows
+ * @return array
+ */
+ public function getFooterTdAttributes(Column $column, $rows, int $index): array
+ {
+ return isset($this->footerTdAttributesCallback) ? call_user_func($this->footerTdAttributesCallback, $column, $rows, $index) : ['default' => true];
+ }
+
+ public function setFooterTrAttributes(Closure $callback): self
+ {
+ $this->footerTrAttributesCallback = $callback;
+
+ return $this;
+ }
+
+ public function setFooterTdAttributes(Closure $callback): self
+ {
+ $this->footerTdAttributesCallback = $callback;
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasLoadingPlaceholderStyling.php b/src/Traits/Styling/HasLoadingPlaceholderStyling.php
index 1dbb2b80d..dcaafb75d 100644
--- a/src/Traits/Styling/HasLoadingPlaceholderStyling.php
+++ b/src/Traits/Styling/HasLoadingPlaceholderStyling.php
@@ -2,14 +2,8 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\LoadingPlaceholderStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\LoadingPlaceholderStylingHelpers;
-
trait HasLoadingPlaceholderStyling
{
- use LoadingPlaceholderStylingConfiguration,
- LoadingPlaceholderStylingHelpers;
-
protected array $loadingPlaceHolderAttributes = [];
protected array $loadingPlaceHolderIconAttributes = [];
@@ -19,4 +13,60 @@ trait HasLoadingPlaceholderStyling
protected array $loadingPlaceHolderRowAttributes = [];
protected array $loadingPlaceHolderCellAttributes = ['class' => '', 'default' => true];
+
+ public function getLoadingPlaceholderAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: true, classicMode: true);
+
+ }
+
+ public function getLoadingPlaceHolderIconAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: true, classicMode: true);
+
+ }
+
+ public function getLoadingPlaceHolderWrapperAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true);
+ }
+
+ public function getLoadingPlaceHolderRowAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true);
+ }
+
+ public function getLoadingPlaceHolderCellAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderCellAttributes', default: true, classicMode: true);
+
+ }
+
+ public function setLoadingPlaceHolderAttributes(array $attributes): self
+ {
+ $this->setCustomAttributes('loadingPlaceHolderAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: false, classicMode: true), ...$attributes]);
+
+ return $this;
+ }
+
+ public function setLoadingPlaceHolderIconAttributes(array $attributes): self
+ {
+ $this->setCustomAttributes('loadingPlaceHolderIconAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: false, classicMode: true), ...$attributes]);
+
+ return $this;
+ }
+
+ public function setLoadingPlaceHolderRowAttributes(array $attributes): self
+ {
+ $this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]);
+
+ return $this;
+ }
+
+ public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self
+ {
+ $this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]);
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasPaginationStyling.php b/src/Traits/Styling/HasPaginationStyling.php
index 907758656..840353348 100644
--- a/src/Traits/Styling/HasPaginationStyling.php
+++ b/src/Traits/Styling/HasPaginationStyling.php
@@ -2,15 +2,43 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\PaginationStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\PaginationStylingHelpers;
+use Illuminate\View\ComponentAttributeBag;
+use Livewire\Attributes\Computed;
trait HasPaginationStyling
{
- use PaginationStylingConfiguration,
- PaginationStylingHelpers;
-
protected array $perPageFieldAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => ''];
protected array $paginationWrapperAttributes = ['class' => ''];
+
+ #[Computed]
+ public function getPerPageFieldAttributes(): array
+ {
+ return $this->perPageFieldAttributes;
+ }
+
+ public function getPaginationWrapperAttributes(): array
+ {
+ return $this->paginationWrapperAttributes ?? ['class' => ''];
+ }
+
+ #[Computed]
+ public function getPaginationWrapperAttributesBag(): ComponentAttributeBag
+ {
+ return new ComponentAttributeBag($this->getPaginationWrapperAttributes());
+ }
+
+ public function setPerPageFieldAttributes(array $attributes = []): self
+ {
+ $this->perPageFieldAttributes = [...$this->perPageFieldAttributes, ...$attributes];
+
+ return $this;
+ }
+
+ public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self
+ {
+ $this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes);
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasReorderStyling.php b/src/Traits/Styling/HasReorderStyling.php
index cc946cd61..793328c18 100644
--- a/src/Traits/Styling/HasReorderStyling.php
+++ b/src/Traits/Styling/HasReorderStyling.php
@@ -2,13 +2,36 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\ReorderStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\ReorderStylingHelpers;
+use Livewire\Attributes\Computed;
trait HasReorderStyling
{
- use ReorderStylingConfiguration,
- ReorderStylingHelpers;
-
protected array $reorderThAttributes = ['default' => true];
+
+ /**
+ * Used to get attributes for the for Bulk Actions
+ *
+ * @return array
+ */
+ #[Computed]
+ public function getReorderThAttributes(): array
+ {
+ return $this->reorderThAttributes ?? ['default' => true];
+ }
+
+ #[Computed]
+ public function hasReorderThAttributes(): bool
+ {
+ return $this->getReorderThAttributes() != ['default' => true];
+ }
+
+ /**
+ * Used to set attributes for the for Reorder Column
+ */
+ public function setReorderThAttributes(array $reorderThAttributes): self
+ {
+ $this->reorderThAttributes = [...$this->reorderThAttributes, ...$reorderThAttributes];
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasSecondaryHeaderStyling.php b/src/Traits/Styling/HasSecondaryHeaderStyling.php
index 036084bbd..08fba6173 100644
--- a/src/Traits/Styling/HasSecondaryHeaderStyling.php
+++ b/src/Traits/Styling/HasSecondaryHeaderStyling.php
@@ -3,15 +3,43 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
use Closure;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\SecondaryHeaderStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\SecondaryHeaderStylingHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Column;
trait HasSecondaryHeaderStyling
{
- use SecondaryHeaderStylingConfiguration,
- SecondaryHeaderStylingHelpers;
-
protected ?Closure $secondaryHeaderTrAttributesCallback;
protected ?Closure $secondaryHeaderTdAttributesCallback;
+
+ /**
+ * @param mixed $rows
+ * @return array
+ */
+ public function getSecondaryHeaderTrAttributes($rows): array
+ {
+ return isset($this->secondaryHeaderTrAttributesCallback) ? call_user_func($this->secondaryHeaderTrAttributesCallback, $rows) : ['default' => true];
+ }
+
+ /**
+ * @param mixed $rows
+ * @return array
+ */
+ public function getSecondaryHeaderTdAttributes(Column $column, $rows, int $index): array
+ {
+ return isset($this->secondaryHeaderTdAttributesCallback) ? call_user_func($this->secondaryHeaderTdAttributesCallback, $column, $rows, $index) : ['default' => true];
+ }
+
+ public function setSecondaryHeaderTrAttributes(Closure $callback): self
+ {
+ $this->secondaryHeaderTrAttributesCallback = $callback;
+
+ return $this;
+ }
+
+ public function setSecondaryHeaderTdAttributes(Closure $callback): self
+ {
+ $this->secondaryHeaderTdAttributesCallback = $callback;
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasSortingPillsStyling.php b/src/Traits/Styling/HasSortingPillsStyling.php
index ecb8044e3..1fc3ab938 100644
--- a/src/Traits/Styling/HasSortingPillsStyling.php
+++ b/src/Traits/Styling/HasSortingPillsStyling.php
@@ -2,17 +2,52 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\SortingPillsStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\SortingPillsStylingHelpers;
+use Livewire\Attributes\Computed;
trait HasSortingPillsStyling
{
- use SortingPillsStylingConfiguration,
- SortingPillsStylingHelpers;
-
protected array $sortingPillsItemAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => ''];
protected array $sortingPillsClearSortButtonAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => ''];
protected array $sortingPillsClearAllButtonAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => ''];
+
+ #[Computed]
+ public function getSortingPillsItemAttributes(): array
+ {
+ return $this->sortingPillsItemAttributes;
+ }
+
+ #[Computed]
+ public function getSortingPillsClearSortButtonAttributes(): array
+ {
+ return $this->sortingPillsClearSortButtonAttributes;
+ }
+
+ #[Computed]
+ public function getSortingPillsClearAllButtonAttributes(): array
+ {
+ return $this->sortingPillsClearAllButtonAttributes;
+ }
+
+ public function setSortingPillsItemAttributes(array $attributes = []): self
+ {
+ $this->sortingPillsItemAttributes = [...$this->sortingPillsItemAttributes, ...$attributes];
+
+ return $this;
+ }
+
+ public function setSortingPillsClearSortButtonAttributes(array $attributes = []): self
+ {
+ $this->sortingPillsClearSortButtonAttributes = [...$this->sortingPillsClearSortButtonAttributes, ...$attributes];
+
+ return $this;
+ }
+
+ public function setSortingPillsClearAllButtonAttributes(array $attributes = []): self
+ {
+ $this->sortingPillsClearAllButtonAttributes = [...$this->sortingPillsClearAllButtonAttributes, ...$attributes];
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/HasToolsStyling.php b/src/Traits/Styling/HasToolsStyling.php
index a56123311..b1026a49c 100644
--- a/src/Traits/Styling/HasToolsStyling.php
+++ b/src/Traits/Styling/HasToolsStyling.php
@@ -2,15 +2,50 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Styling;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\ToolsStylingConfiguration;
-use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\ToolsStylingHelpers;
+use Illuminate\View\ComponentAttributeBag;
+use Livewire\Attributes\Computed;
trait HasToolsStyling
{
- use ToolsStylingConfiguration,
- ToolsStylingHelpers;
-
protected array $toolsAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true];
protected array $toolBarAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true];
+
+ #[Computed]
+ public function getToolsAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'toolsAttributes', default: false, classicMode: false);
+ }
+
+ #[Computed]
+ public function getToolsAttributesBag(): ComponentAttributeBag
+ {
+ return $this->getCustomAttributesBagFromArray($this->getToolsAttributes());
+ }
+
+ protected function getToolBarAttributes(): array
+ {
+ return $this->getCustomAttributes(propertyName: 'toolBarAttributes', default: false, classicMode: false);
+ }
+
+ #[Computed]
+ public function getToolBarAttributesBag(): ComponentAttributeBag
+ {
+ return $this->getCustomAttributesBagFromArray($this->getToolBarAttributes());
+
+ }
+
+ public function setToolsAttributes(array $toolsAttributes = []): self
+ {
+ $this->setCustomAttributes(propertyName: 'toolsAttributes', customAttributes: $toolsAttributes);
+
+ return $this;
+ }
+
+ public function setToolBarAttributes(array $toolBarAttributes = []): self
+ {
+ $this->setCustomAttributes(propertyName: 'toolBarAttributes', customAttributes: $toolBarAttributes);
+
+ return $this;
+ }
}
diff --git a/src/Traits/Styling/Helpers/ActionsStylingHelpers.php b/src/Traits/Styling/Helpers/ActionsStylingHelpers.php
deleted file mode 100644
index b2476f647..000000000
--- a/src/Traits/Styling/Helpers/ActionsStylingHelpers.php
+++ /dev/null
@@ -1,14 +0,0 @@
- '', 'default-styling' => true, 'default-colors' => true], ...$this->actionWrapperAttributes];
- }
-}
diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php
deleted file mode 100644
index adc3cea89..000000000
--- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php
+++ /dev/null
@@ -1,115 +0,0 @@
-
- */
- #[Computed]
- public function getBulkActionsButtonAttributes(): array
- {
- return $this->getCustomAttributes('bulkActionsButtonAttributes', true);
-
- }
-
- /**
- * Used to get attributes for the Bulk Actions Menu (Dropdown)
- *
- * @return array
- */
- #[Computed]
- public function getBulkActionsMenuAttributes(): array
- {
- return $this->getCustomAttributes('bulkActionsMenuAttributes', true, false);
-
- }
-
- /**
- * Used to get attributes for the items in the Bulk Actions Menu (Dropdown)
- *
- * @return array
- */
- #[Computed]
- public function getBulkActionsMenuItemAttributes(): array
- {
- return $this->getCustomAttributes('bulkActionsMenuItemAttributes', true, false);
-
- }
-
- /**
- * Used to get attributes for the for Bulk Actions
- *
- * @return array
- */
- #[Computed]
- public function getBulkActionsThAttributes(): array
- {
- return $this->getCustomAttributes('bulkActionsThAttributes');
-
- }
-
- /**
- * Used to check if the Bulk Actions TH has any attributes (supports historic approach)
- */
- #[Computed]
- public function hasBulkActionsThAttributes(): bool
- {
- return $this->getBulkActionsThAttributes() != ['default' => true, 'default-colors' => false, 'default-styling' => false];
- }
-
- /**
- * Used to get attributes for the Checkbox for Bulk Actions TH
- *
- * @return array
- */
- public function getBulkActionsThCheckboxAttributes(): array
- {
- return $this->getCustomAttributes('bulkActionsThCheckboxAttributes');
- }
-
- /**
- * Used to get attributes for the Bulk Actions TD
- *
- * @return array
- */
- public function getBulkActionsTdAttributes(): array
- {
- return $this->getCustomAttributes('bulkActionsTdAttributes');
- }
-
- /**
- * Used to get attributes for the Bulk Actions TD
- *
- * @return array
- */
- public function getBulkActionsTdCheckboxAttributes(): array
- {
- return $this->getCustomAttributes('bulkActionsTdCheckboxAttributes');
-
- }
-
- /**
- * Used to get attributes for the Bulk Actions Row Buttons
- *
- * @return array
- */
- #[Computed]
- public function getBulkActionsRowButtonAttributes(): array
- {
- return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true);
-
- }
-
- #[Computed]
- public function getBulkActionsRowButtonAttributesBag(): ComponentAttributeBag
- {
- return $this->getCustomAttributesBagFromArray($this->getBulkActionsRowButtonAttributes());
- }
-}
diff --git a/src/Traits/Styling/Helpers/ColumnSelectStylingHelpers.php b/src/Traits/Styling/Helpers/ColumnSelectStylingHelpers.php
deleted file mode 100644
index 3d0d7c093..000000000
--- a/src/Traits/Styling/Helpers/ColumnSelectStylingHelpers.php
+++ /dev/null
@@ -1,21 +0,0 @@
-columnSelectButtonAttributes;
- }
-
- #[Computed]
- public function getColumnSelectMenuOptionCheckboxAttributes(): array
- {
- return $this->columnSelectMenuOptionCheckboxAttributes;
- }
-}
diff --git a/src/Traits/Styling/Helpers/FooterStylingHelpers.php b/src/Traits/Styling/Helpers/FooterStylingHelpers.php
deleted file mode 100644
index 8fc76e056..000000000
--- a/src/Traits/Styling/Helpers/FooterStylingHelpers.php
+++ /dev/null
@@ -1,26 +0,0 @@
-
- */
- public function getFooterTrAttributes($rows): array
- {
- return isset($this->footerTrAttributesCallback) ? call_user_func($this->footerTrAttributesCallback, $rows) : ['default' => true];
- }
-
- /**
- * @param mixed $rows
- * @return array
- */
- public function getFooterTdAttributes(Column $column, $rows, int $index): array
- {
- return isset($this->footerTdAttributesCallback) ? call_user_func($this->footerTdAttributesCallback, $column, $rows, $index) : ['default' => true];
- }
-}
diff --git a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php
deleted file mode 100644
index 9cce416dd..000000000
--- a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php
+++ /dev/null
@@ -1,34 +0,0 @@
-getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: true, classicMode: true);
-
- }
-
- public function getLoadingPlaceHolderIconAttributes(): array
- {
- return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: true, classicMode: true);
-
- }
-
- public function getLoadingPlaceHolderWrapperAttributes(): array
- {
- return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true);
- }
-
- public function getLoadingPlaceHolderRowAttributes(): array
- {
- return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true);
- }
-
- public function getLoadingPlaceHolderCellAttributes(): array
- {
- return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderCellAttributes', default: true, classicMode: true);
-
- }
-}
diff --git a/src/Traits/Styling/Helpers/PaginationStylingHelpers.php b/src/Traits/Styling/Helpers/PaginationStylingHelpers.php
deleted file mode 100644
index 064db4cdf..000000000
--- a/src/Traits/Styling/Helpers/PaginationStylingHelpers.php
+++ /dev/null
@@ -1,26 +0,0 @@
-perPageFieldAttributes;
- }
-
- public function getPaginationWrapperAttributes(): array
- {
- return $this->paginationWrapperAttributes ?? ['class' => ''];
- }
-
- #[Computed]
- public function getPaginationWrapperAttributesBag(): ComponentAttributeBag
- {
- return new ComponentAttributeBag($this->getPaginationWrapperAttributes());
- }
-}
diff --git a/src/Traits/Styling/Helpers/ReorderStylingHelpers.php b/src/Traits/Styling/Helpers/ReorderStylingHelpers.php
deleted file mode 100644
index 2f6020d55..000000000
--- a/src/Traits/Styling/Helpers/ReorderStylingHelpers.php
+++ /dev/null
@@ -1,25 +0,0 @@
- for Bulk Actions
- *
- * @return array
- */
- #[Computed]
- public function getReorderThAttributes(): array
- {
- return $this->reorderThAttributes ?? ['default' => true];
- }
-
- #[Computed]
- public function hasReorderThAttributes(): bool
- {
- return $this->getReorderThAttributes() != ['default' => true];
- }
-}
diff --git a/src/Traits/Styling/Helpers/SecondaryHeaderStylingHelpers.php b/src/Traits/Styling/Helpers/SecondaryHeaderStylingHelpers.php
deleted file mode 100644
index 785acc107..000000000
--- a/src/Traits/Styling/Helpers/SecondaryHeaderStylingHelpers.php
+++ /dev/null
@@ -1,26 +0,0 @@
-
- */
- public function getSecondaryHeaderTrAttributes($rows): array
- {
- return isset($this->secondaryHeaderTrAttributesCallback) ? call_user_func($this->secondaryHeaderTrAttributesCallback, $rows) : ['default' => true];
- }
-
- /**
- * @param mixed $rows
- * @return array
- */
- public function getSecondaryHeaderTdAttributes(Column $column, $rows, int $index): array
- {
- return isset($this->secondaryHeaderTdAttributesCallback) ? call_user_func($this->secondaryHeaderTdAttributesCallback, $column, $rows, $index) : ['default' => true];
- }
-}
diff --git a/src/Traits/Styling/Helpers/SortingPillsStylingHelpers.php b/src/Traits/Styling/Helpers/SortingPillsStylingHelpers.php
deleted file mode 100644
index a6d560797..000000000
--- a/src/Traits/Styling/Helpers/SortingPillsStylingHelpers.php
+++ /dev/null
@@ -1,26 +0,0 @@
-sortingPillsItemAttributes;
- }
-
- #[Computed]
- public function getSortingPillsClearSortButtonAttributes(): array
- {
- return $this->sortingPillsClearSortButtonAttributes;
- }
-
- #[Computed]
- public function getSortingPillsClearAllButtonAttributes(): array
- {
- return $this->sortingPillsClearAllButtonAttributes;
- }
-}
diff --git a/src/Traits/Styling/Helpers/ToolsStylingHelpers.php b/src/Traits/Styling/Helpers/ToolsStylingHelpers.php
deleted file mode 100644
index f211e9014..000000000
--- a/src/Traits/Styling/Helpers/ToolsStylingHelpers.php
+++ /dev/null
@@ -1,33 +0,0 @@
-getCustomAttributes(propertyName: 'toolsAttributes', default: false, classicMode: false);
- }
-
- #[Computed]
- public function getToolsAttributesBag(): ComponentAttributeBag
- {
- return $this->getCustomAttributesBagFromArray($this->getToolsAttributes());
- }
-
- protected function getToolBarAttributes(): array
- {
- return $this->getCustomAttributes(propertyName: 'toolBarAttributes', default: false, classicMode: false);
- }
-
- #[Computed]
- public function getToolBarAttributesBag(): ComponentAttributeBag
- {
- return $this->getCustomAttributesBagFromArray($this->getToolBarAttributes());
-
- }
-}
diff --git a/src/Views/Action.php b/src/Views/Action.php
index 6775a75c3..bbba77c81 100644
--- a/src/Views/Action.php
+++ b/src/Views/Action.php
@@ -4,8 +4,7 @@
use Illuminate\View\Component;
use Rappasoft\LaravelLivewireTables\Traits\Core\HasLocalisations;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Actions\{HasActionAttributes, HasRoute};
-use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\HasVisibility;
+use Rappasoft\LaravelLivewireTables\Views\Actions\Traits\{HasActionAttributes, HasRoute, HasVisibility};
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasIcon, HasLabel, HasLabelAttributes, HasTheme, HasView, HasWireActions};
class Action extends Component
diff --git a/src/Views/Traits/Actions/HasActionAttributes.php b/src/Views/Actions/Traits/HasActionAttributes.php
similarity index 93%
rename from src/Views/Traits/Actions/HasActionAttributes.php
rename to src/Views/Actions/Traits/HasActionAttributes.php
index 1ff1dc66c..09cf69618 100644
--- a/src/Views/Traits/Actions/HasActionAttributes.php
+++ b/src/Views/Actions/Traits/HasActionAttributes.php
@@ -1,6 +1,6 @@
hidden === true;
}
- /**
- * @param mixed $condition
- */
- public function hideIf($condition): self
+ public function hideIf(mixed $condition): self
{
$this->hidden = $condition;
diff --git a/src/Views/Column.php b/src/Views/Column.php
index b7e6ea0de..6c18d8d29 100644
--- a/src/Views/Column.php
+++ b/src/Views/Column.php
@@ -3,14 +3,12 @@
namespace Rappasoft\LaravelLivewireTables\Views;
use Illuminate\Support\Str;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\IsColumn;
class Column
{
use IsColumn;
- protected bool $displayColumnLabel = true;
-
protected string $view = '';
public function __construct(string $title, ?string $from = null)
diff --git a/src/Views/Columns/AggregateColumn.php b/src/Views/Columns/AggregateColumn.php
index a284b08ff..a61afd2c2 100644
--- a/src/Views/Columns/AggregateColumn.php
+++ b/src/Views/Columns/AggregateColumn.php
@@ -3,7 +3,7 @@
namespace Rappasoft\LaravelLivewireTables\Views\Columns;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsAggregateColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\IsAggregateColumn;
class AggregateColumn extends Column
{
diff --git a/src/Views/Columns/ArrayColumn.php b/src/Views/Columns/ArrayColumn.php
index be9366db0..26d39dbfd 100644
--- a/src/Views/Columns/ArrayColumn.php
+++ b/src/Views/Columns/ArrayColumn.php
@@ -2,16 +2,19 @@
namespace Rappasoft\LaravelLivewireTables\Views\Columns;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\HtmlString;
+use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ArrayColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\ArrayColumnHelpers;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\ArrayColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\ArrayColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\IsColumn;
class ArrayColumn extends Column
{
use IsColumn,
ArrayColumnConfiguration,
- ArrayColumnHelpers { ArrayColumnHelpers::getContents insteadof IsColumn; }
+ ArrayColumnHelpers;
public string $separator = ' ';
@@ -28,4 +31,24 @@ public function __construct(string $title, ?string $from = null)
$this->label(fn () => null);
}
}
+
+ public function getContents(Model $row): null|string|\BackedEnum|HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
+ {
+ $outputValues = [];
+ $value = $this->getValue($row);
+
+ if (! $this->hasDataCallback()) {
+ throw new DataTableConfigurationException('You must set a data() method on an ArrayColumn');
+ }
+
+ if (! $this->hasOutputFormatCallback()) {
+ throw new DataTableConfigurationException('You must set an outputFormat() method on an ArrayColumn');
+ }
+
+ foreach (call_user_func($this->getDataCallback(), $value, $row) as $i => $v) {
+ $outputValues[] = call_user_func($this->getOutputFormatCallback(), $i, $v);
+ }
+
+ return new HtmlString((! empty($outputValues) ? implode($this->getSeparator(), $outputValues) : $this->getEmptyValue()));
+ }
}
diff --git a/src/Views/Columns/AvgColumn.php b/src/Views/Columns/AvgColumn.php
index 3af197873..a15667cb7 100644
--- a/src/Views/Columns/AvgColumn.php
+++ b/src/Views/Columns/AvgColumn.php
@@ -2,7 +2,7 @@
namespace Rappasoft\LaravelLivewireTables\Views\Columns;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsAggregateColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\IsAggregateColumn;
class AvgColumn extends AggregateColumn
{
diff --git a/src/Views/Columns/BooleanColumn.php b/src/Views/Columns/BooleanColumn.php
index e7ae20a66..518b398ed 100644
--- a/src/Views/Columns/BooleanColumn.php
+++ b/src/Views/Columns/BooleanColumn.php
@@ -5,10 +5,9 @@
use Illuminate\Database\Eloquent\Model;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\BooleanColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasCallback;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasConfirmation;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\BooleanColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\BooleanColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\BooleanColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasCallback,HasConfirmation};
class BooleanColumn extends Column
{
@@ -35,15 +34,17 @@ public function getContents(Model $row): null|string|\Illuminate\Support\HtmlStr
$value = $this->getValue($row);
- return $this->getColumnViewWithDefaults()
+ return view($this->getView())
->withRowPrimaryKey($row->{$row->getKeyName()})
->withIsToggleable($this->getIsToggleable())
->withToggleMethod($this->getIsToggleable() ? $this->getToggleMethod() : '')
->withHasConfirmMessage($this->hasConfirmMessage())
->withConfirmMessage($this->hasConfirmMessage() ? $this->getConfirmMessage() : '')
+ ->withIsTailwind($this->isTailwind())
+ ->withIsBootstrap($this->isBootstrap())
->withSuccessValue($this->getSuccessValue())
- ->withType($this->getType())
->withValue($value)
+ ->withType($this->getType())
->withStatus($this->hasCallback() ? call_user_func($this->getCallback(), $value, $row) : (bool) $value === true);
}
}
diff --git a/src/Views/Columns/ButtonGroupColumn.php b/src/Views/Columns/ButtonGroupColumn.php
index bf1fd2560..519bb4352 100644
--- a/src/Views/Columns/ButtonGroupColumn.php
+++ b/src/Views/Columns/ButtonGroupColumn.php
@@ -4,8 +4,8 @@
use Illuminate\Database\Eloquent\Model;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ButtonGroupColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\ButtonGroupColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\ButtonGroupColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\ButtonGroupColumnHelpers;
class ButtonGroupColumn extends Column
{
@@ -20,16 +20,16 @@ public function __construct(string $title, ?string $from = null)
{
parent::__construct($title, $from);
- if (! isset($from)) {
- $this->label(fn () => null);
- }
+ $this->label(fn () => null);
}
public function getContents(Model $row): null|string|\Illuminate\Support\HtmlString|\Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
{
- return $this->getColumnViewWithDefaults()
+ return view($this->getView())
->withColumn($this)
->withRow($row)
+ ->withIsTailwind($this->isTailwind())
+ ->withIsBootstrap($this->isBootstrap())
->withButtons($this->getButtons())
->withAttributes($this->hasAttributesCallback() ? app()->call($this->getAttributesCallback(), ['row' => $row]) : []);
}
diff --git a/src/Views/Columns/ColorColumn.php b/src/Views/Columns/ColorColumn.php
index 21e9100cd..e5caccbdc 100644
--- a/src/Views/Columns/ColorColumn.php
+++ b/src/Views/Columns/ColorColumn.php
@@ -2,14 +2,12 @@
namespace Rappasoft\LaravelLivewireTables\Views\Columns;
-use Closure;
use Illuminate\Database\Eloquent\Model;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\HasDefaultStringValue;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ColorColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\ColorColumnHelpers;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\ColorColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\ColorColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\{HasDefaultStringValue, IsColumn};
class ColorColumn extends Column
{
@@ -18,7 +16,7 @@ class ColorColumn extends Column
ColorColumnHelpers;
use HasDefaultStringValue;
- public ?Closure $colorCallback;
+ public ?\Closure $colorCallback;
protected string $view = 'livewire-tables::includes.columns.color';
@@ -33,7 +31,9 @@ public function __construct(string $title, ?string $from = null)
public function getContents(Model $row): null|string|\Illuminate\Support\HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
{
- return $this->getColumnViewWithDefaults()
+ return view($this->getView())
+ ->withIsTailwind($this->isTailwind())
+ ->withIsBootstrap($this->isBootstrap())
->withColor($this->getColor($row))
->withAttributeBag($this->getAttributeBag($row));
}
diff --git a/src/Views/Columns/ComponentColumn.php b/src/Views/Columns/ComponentColumn.php
index ad4b4ee60..b794eff3e 100644
--- a/src/Views/Columns/ComponentColumn.php
+++ b/src/Views/Columns/ComponentColumn.php
@@ -7,14 +7,16 @@
use Illuminate\View\ComponentAttributeBag;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\{HasComponentView, HasSlot};
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ComponentColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\ComponentColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\ComponentColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\ComponentColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\{HasComponentView,HasSlot};
class ComponentColumn extends Column
{
use HasComponentView,
- HasSlot;
+ HasSlot,
+ ComponentColumnConfiguration,
+ ComponentColumnHelpers;
public function __construct(string $title, ?string $from = null)
{
@@ -43,7 +45,10 @@ public function getContents(Model $row): null|string|HtmlString|DataTableConfigu
}
}
if ($this->hasSlotCallback()) {
- $slotContent = $this->getSlotContent($row, $value);
+ $slotContent = call_user_func($this->getSlotCallback(), $value, $row, $this);
+ if (is_string($slotContent)) {
+ $slotContent = new HtmlString($slotContent);
+ }
}
return view($this->getComponentView(), [
diff --git a/src/Views/Columns/CountColumn.php b/src/Views/Columns/CountColumn.php
index 4a1ffd812..edc5ed3a0 100644
--- a/src/Views/Columns/CountColumn.php
+++ b/src/Views/Columns/CountColumn.php
@@ -2,7 +2,7 @@
namespace Rappasoft\LaravelLivewireTables\Views\Columns;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsAggregateColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\IsAggregateColumn;
class CountColumn extends AggregateColumn
{
diff --git a/src/Views/Columns/DateColumn.php b/src/Views/Columns/DateColumn.php
index 04100667a..d4ccdd2f5 100644
--- a/src/Views/Columns/DateColumn.php
+++ b/src/Views/Columns/DateColumn.php
@@ -8,14 +8,15 @@
use Illuminate\Support\HtmlString;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\DateColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\DateColumnHelpers;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\DateColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\DateColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\{HasInputOutputFormat, IsColumn};
class DateColumn extends Column
{
- use IsColumn;
- use DateColumnConfiguration,
+ use IsColumn,
+ HasInputOutputFormat,
+ DateColumnConfiguration,
DateColumnHelpers { DateColumnHelpers::getValue insteadof IsColumn; }
public string $inputFormat = 'Y-m-d';
diff --git a/src/Views/Columns/IconColumn.php b/src/Views/Columns/IconColumn.php
index 3dd264b2c..4f76c665a 100644
--- a/src/Views/Columns/IconColumn.php
+++ b/src/Views/Columns/IconColumn.php
@@ -6,13 +6,11 @@
use Illuminate\Database\Eloquent\Model;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\IconColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\IconColumnHelpers;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\IconColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\IconColumnHelpers;
class IconColumn extends Column
{
- use IsColumn;
use IconColumnConfiguration,
IconColumnHelpers;
diff --git a/src/Views/Columns/ImageColumn.php b/src/Views/Columns/ImageColumn.php
index 444fc486f..1c3dc3f7f 100644
--- a/src/Views/Columns/ImageColumn.php
+++ b/src/Views/Columns/ImageColumn.php
@@ -5,9 +5,9 @@
use Illuminate\Database\Eloquent\Model;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ImageColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\ImageColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\ImageColumnHelpers;
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasLocationCallback;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\ImageColumnHelpers;
class ImageColumn extends Column
{
@@ -20,10 +20,8 @@ class ImageColumn extends Column
public function __construct(string $title, ?string $from = null)
{
parent::__construct($title, $from);
- if (! isset($from)) {
- $this->label(fn () => null);
- }
+ $this->label(fn () => null);
}
public function getContents(Model $row): null|string|\Illuminate\Support\HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
@@ -32,8 +30,10 @@ public function getContents(Model $row): null|string|\Illuminate\Support\HtmlStr
throw new DataTableConfigurationException('You must specify a location callback for an image column.');
}
- return $this->getColumnViewWithDefaults()
+ return view($this->getView())
->withColumn($this)
+ ->withIsTailwind($this->isTailwind())
+ ->withIsBootstrap($this->isBootstrap())
->withPath(app()->call($this->getLocationCallback(), ['row' => $row]))
->withAttributes($this->hasAttributesCallback() ? app()->call($this->getAttributesCallback(), ['row' => $row]) : []);
}
diff --git a/src/Views/Columns/LinkColumn.php b/src/Views/Columns/LinkColumn.php
index 0e58b646a..2c024e391 100644
--- a/src/Views/Columns/LinkColumn.php
+++ b/src/Views/Columns/LinkColumn.php
@@ -5,9 +5,9 @@
use Illuminate\Database\Eloquent\Model;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\LinkColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasLocationCallback, HasTitleCallback};
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\LinkColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\LinkColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\LinkColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasLocationCallback,HasTitleCallback};
class LinkColumn extends Column
{
@@ -22,9 +22,7 @@ public function __construct(string $title, ?string $from = null)
{
parent::__construct($title, $from);
- if (! isset($from)) {
- $this->label(fn () => null);
- }
+ $this->label(fn () => null);
}
public function getContents(Model $row): null|string|\Illuminate\Support\HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
@@ -37,8 +35,10 @@ public function getContents(Model $row): null|string|\Illuminate\Support\HtmlStr
throw new DataTableConfigurationException('You must specify a location callback for an link column.');
}
- return $this->getColumnViewWithDefaults()
+ return view($this->getView())
->withColumn($this)
+ ->withIsTailwind($this->isTailwind())
+ ->withIsBootstrap($this->isBootstrap())
->withTitle(app()->call($this->getTitleCallback(), ['row' => $row]))
->withPath(app()->call($this->getLocationCallback(), ['row' => $row]))
->withAttributes($this->hasAttributesCallback() ? app()->call($this->getAttributesCallback(), ['row' => $row]) : []);
diff --git a/src/Views/Columns/LivewireComponentColumn.php b/src/Views/Columns/LivewireComponentColumn.php
index add573962..0049c338a 100644
--- a/src/Views/Columns/LivewireComponentColumn.php
+++ b/src/Views/Columns/LivewireComponentColumn.php
@@ -8,8 +8,8 @@
use Illuminate\Support\Str;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\LivewireComponentColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\LivewireComponentColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\LivewireComponentColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\LivewireComponentColumnHelpers;
class LivewireComponentColumn extends Column
{
@@ -17,4 +17,39 @@ class LivewireComponentColumn extends Column
LivewireComponentColumnHelpers;
protected ?string $livewireComponent;
+
+ public function getContents(Model $row): null|string|HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
+ {
+ if (! $this->hasLivewireComponent()) {
+ throw new DataTableConfigurationException('You must define a Livewire Component for this column');
+ }
+
+ if ($this->isLabel()) {
+ throw new DataTableConfigurationException('You can not use a label column with a Livewire Component column');
+ }
+
+ $attributes = [];
+ $value = $this->getValue($row);
+
+ if ($this->hasAttributesCallback()) {
+ $attributes = call_user_func($this->getAttributesCallback(), $value, $row, $this);
+
+ if (! is_array($attributes)) {
+ throw new DataTableConfigurationException('The return type of callback must be an array');
+ }
+ }
+
+ $implodedAttributes = collect($attributes)->map(function ($value, $key) {
+ return ':'.$key.'="$'.$key.'"';
+ })->implode(' ');
+
+ return new HtmlString(Blade::render(
+ '',
+ [
+ 'component' => $this->getLivewireComponent(),
+ ...$attributes,
+ ],
+ ));
+
+ }
}
diff --git a/src/Views/Columns/SumColumn.php b/src/Views/Columns/SumColumn.php
index a01822d7b..230198d07 100644
--- a/src/Views/Columns/SumColumn.php
+++ b/src/Views/Columns/SumColumn.php
@@ -2,7 +2,7 @@
namespace Rappasoft\LaravelLivewireTables\Views\Columns;
-use Rappasoft\LaravelLivewireTables\Views\Traits\IsAggregateColumn;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\IsAggregateColumn;
class SumColumn extends AggregateColumn
{
diff --git a/src/Views/Traits/Configuration/AggregateColumnConfiguration.php b/src/Views/Columns/Traits/Configuration/AggregateColumnConfiguration.php
similarity index 95%
rename from src/Views/Traits/Configuration/AggregateColumnConfiguration.php
rename to src/Views/Columns/Traits/Configuration/AggregateColumnConfiguration.php
index 729be2745..6794cc7ac 100644
--- a/src/Views/Traits/Configuration/AggregateColumnConfiguration.php
+++ b/src/Views/Columns/Traits/Configuration/AggregateColumnConfiguration.php
@@ -1,6 +1,6 @@
html = true;
+
+ return $this;
+ }
+
+ public function setTable(string $table): self
+ {
+ $this->table = $table;
+
+ return $this;
+ }
+
+ public function setIndexes(int $rowIndex, int $columnIndex): self
+ {
+ $this->setRowIndex($rowIndex);
+ $this->setColumnIndex($columnIndex);
+
+ return $this;
+ }
+
+ public function setColumnIndex(int $columnIndex): self
+ {
+ $this->columnIndex = $columnIndex;
+
+ return $this;
+ }
+
+ public function setRowIndex(int $rowIndex): self
+ {
+ $this->rowIndex = $rowIndex;
+
+ return $this;
+ }
+}
diff --git a/src/Views/Columns/Traits/Configuration/ComponentColumnConfiguration.php b/src/Views/Columns/Traits/Configuration/ComponentColumnConfiguration.php
new file mode 100644
index 000000000..8615445aa
--- /dev/null
+++ b/src/Views/Columns/Traits/Configuration/ComponentColumnConfiguration.php
@@ -0,0 +1,5 @@
+emptyValue = $emptyValue;
+
+ return $this;
+ }
+}
diff --git a/src/Views/Traits/Configuration/IconColumnConfiguration.php b/src/Views/Columns/Traits/Configuration/IconColumnConfiguration.php
similarity index 70%
rename from src/Views/Traits/Configuration/IconColumnConfiguration.php
rename to src/Views/Columns/Traits/Configuration/IconColumnConfiguration.php
index f938dac4b..47f82a7ee 100644
--- a/src/Views/Traits/Configuration/IconColumnConfiguration.php
+++ b/src/Views/Columns/Traits/Configuration/IconColumnConfiguration.php
@@ -1,6 +1,6 @@
clickable &&
+ $this->getHasTableRowUrl() &&
+ ! $this instanceof LinkColumn;
+ }
+
+ public function getHasTableRowUrl(): bool
+ {
+ return $this->hasTableRowUrl;
+ }
+
+ public function unclickable(): self
+ {
+ $this->clickable = false;
+
+ return $this;
+ }
+
+ public function setHasTableRowUrl(bool $hasTableRowUrl): self
+ {
+ $this->hasTableRowUrl = $hasTableRowUrl;
+
+ return $this;
+ }
+}
diff --git a/src/Views/Columns/Traits/HasColumnLabelStatus.php b/src/Views/Columns/Traits/HasColumnLabelStatus.php
new file mode 100644
index 000000000..d32079469
--- /dev/null
+++ b/src/Views/Columns/Traits/HasColumnLabelStatus.php
@@ -0,0 +1,30 @@
+displayColumnLabel ?? true;
+ }
+
+ public function setColumnLabelStatus(bool $status): self
+ {
+ $this->displayColumnLabel = $status;
+
+ return $this;
+ }
+
+ public function setColumnLabelStatusEnabled(): self
+ {
+ return $this->setColumnLabelStatus(true);
+ }
+
+ public function setColumnLabelStatusDisabled(): self
+ {
+ return $this->setColumnLabelStatus(false);
+ }
+}
diff --git a/src/Views/Traits/Columns/HasColumnView.php b/src/Views/Columns/Traits/HasColumnView.php
similarity index 93%
rename from src/Views/Traits/Columns/HasColumnView.php
rename to src/Views/Columns/Traits/HasColumnView.php
index 57d952cac..5abbc7a50 100644
--- a/src/Views/Traits/Columns/HasColumnView.php
+++ b/src/Views/Columns/Traits/HasColumnView.php
@@ -1,6 +1,6 @@
component = $component;
+
+ return $this;
+ }
+
+ public function hasComponent(): bool
+ {
+ return isset($this->component) && ! is_null($this->component);
+ }
+
+ public function getComponent(): ?DataTableComponent
+ {
+ return $this->component;
+ }
+}
diff --git a/src/Views/Traits/Columns/HasDefaultStringValue.php b/src/Views/Columns/Traits/HasDefaultStringValue.php
similarity index 83%
rename from src/Views/Traits/Columns/HasDefaultStringValue.php
rename to src/Views/Columns/Traits/HasDefaultStringValue.php
index e40ffe054..1e1bf664a 100644
--- a/src/Views/Traits/Columns/HasDefaultStringValue.php
+++ b/src/Views/Columns/Traits/HasDefaultStringValue.php
@@ -1,6 +1,6 @@
emptyValue = $emptyValue;
+ return $this->outputFormat;
+ }
- return $this;
+ /**
+ * Retrieve the inputFormat to use for the Column
+ */
+ public function getInputFormat(): string
+ {
+ return $this->inputFormat;
}
}
diff --git a/src/Views/Columns/Traits/HasLabelFormat.php b/src/Views/Columns/Traits/HasLabelFormat.php
new file mode 100644
index 000000000..e6271137f
--- /dev/null
+++ b/src/Views/Columns/Traits/HasLabelFormat.php
@@ -0,0 +1,44 @@
+formatCallback !== null;
+ }
+
+ public function getFormatCallback(): ?callable
+ {
+ return $this->formatCallback;
+ }
+
+ // TODO
+ public function getLabelCallback(): ?callable
+ {
+ return $this->labelCallback;
+ }
+
+ public function label(callable $callback): self
+ {
+ $this->from = null;
+ $this->field = null;
+ $this->labelCallback = $callback;
+
+ return $this;
+ }
+
+ public function format(callable $callable): Column
+ {
+ $this->formatCallback = $callable;
+
+ return $this;
+ }
+}
diff --git a/src/Views/Traits/Helpers/RelationshipHelpers.php b/src/Views/Columns/Traits/HasRelations.php
similarity index 52%
rename from src/Views/Traits/Helpers/RelationshipHelpers.php
rename to src/Views/Columns/Traits/HasRelations.php
index 50087c081..b55cde180 100644
--- a/src/Views/Traits/Helpers/RelationshipHelpers.php
+++ b/src/Views/Columns/Traits/HasRelations.php
@@ -1,11 +1,16 @@
['address', 'group']
+ protected array $relations = [];
+
+ protected bool $eagerLoadRelations = false;
+
public function isBaseColumn(): bool
{
return ! $this->hasRelations() && $this->hasField();
@@ -29,4 +34,16 @@ public function getRelationString(): ?string
return null;
}
+
+ public function eagerLoadRelations(): self
+ {
+ $this->eagerLoadRelations = true;
+
+ return $this;
+ }
+
+ public function eagerLoadRelationsIsEnabled(): bool
+ {
+ return $this->eagerLoadRelations === true;
+ }
}
diff --git a/src/Views/Traits/Core/HasSecondaryHeader.php b/src/Views/Columns/Traits/HasSecondaryHeader.php
similarity index 96%
rename from src/Views/Traits/Core/HasSecondaryHeader.php
rename to src/Views/Columns/Traits/HasSecondaryHeader.php
index 3c47fb289..54738302a 100644
--- a/src/Views/Traits/Core/HasSecondaryHeader.php
+++ b/src/Views/Columns/Traits/HasSecondaryHeader.php
@@ -1,6 +1,6 @@
secondaryHeaderCallback !== null;
}
- /**
- * @return mixed
- */
- public function getSecondaryHeaderCallback()
+ public function getSecondaryHeaderCallback(): mixed
{
return $this->secondaryHeaderCallback;
}
diff --git a/src/Views/Traits/Columns/HasSlot.php b/src/Views/Columns/Traits/HasSlot.php
similarity index 92%
rename from src/Views/Traits/Columns/HasSlot.php
rename to src/Views/Columns/Traits/HasSlot.php
index aecfffc77..c6aaec08c 100644
--- a/src/Views/Traits/Columns/HasSlot.php
+++ b/src/Views/Columns/Traits/HasSlot.php
@@ -1,6 +1,6 @@
hasCustomSlug() ? $this->getCustomSlug() : $this->getTitle());
+ }
+
+ public function getCustomSlug(): string
+ {
+ return $this->customSlug;
+ }
+
+ public function hasCustomSlug(): bool
+ {
+ return $this->customSlug !== null;
+ }
+
+ public function setCustomSlug(string $customSlug): self
+ {
+ $this->customSlug = $customSlug;
+
+ return $this;
+ }
+
+ public function isColumnBySlug(string $slug): bool
+ {
+ return $this->getSlug() === $slug;
+ }
+}
diff --git a/src/Views/Columns/Traits/HasVisibility.php b/src/Views/Columns/Traits/HasVisibility.php
new file mode 100644
index 000000000..29dfb8f82
--- /dev/null
+++ b/src/Views/Columns/Traits/HasVisibility.php
@@ -0,0 +1,25 @@
+hidden !== true;
+ }
+
+ public function isHidden(): bool
+ {
+ return $this->hidden === true;
+ }
+
+ public function hideIf(mixed $condition): self
+ {
+ $this->hidden = $condition;
+
+ return $this;
+ }
+}
diff --git a/src/Views/Traits/Helpers/AggregateColumnHelpers.php b/src/Views/Columns/Traits/Helpers/AggregateColumnHelpers.php
similarity index 93%
rename from src/Views/Traits/Helpers/AggregateColumnHelpers.php
rename to src/Views/Columns/Traits/Helpers/AggregateColumnHelpers.php
index 5ea2d7690..f9f574ca8 100644
--- a/src/Views/Traits/Helpers/AggregateColumnHelpers.php
+++ b/src/Views/Columns/Traits/Helpers/AggregateColumnHelpers.php
@@ -1,6 +1,6 @@
separator !== null && is_string($this->separator);
+ }
+
+ public function getSeparator(): string
+ {
+ return $this->separator;
+ }
+
+ public function getEmptyValue(): string
+ {
+ return $this->emptyValue;
+ }
+
+ public function hasDataCallback(): bool
+ {
+ return isset($this->dataCallback) && is_callable($this->dataCallback);
+ }
+
+ public function getDataCallback(): ?callable
+ {
+ return $this->dataCallback;
+ }
+
+ public function hasOutputFormatCallback(): bool
+ {
+ return isset($this->outputFormat) && is_callable($this->outputFormat);
+ }
+
+ public function getOutputFormatCallback(): ?callable
+ {
+ return $this->outputFormat;
+ }
+}
diff --git a/src/Views/Traits/Helpers/BooleanColumnHelpers.php b/src/Views/Columns/Traits/Helpers/BooleanColumnHelpers.php
similarity index 85%
rename from src/Views/Traits/Helpers/BooleanColumnHelpers.php
rename to src/Views/Columns/Traits/Helpers/BooleanColumnHelpers.php
index 200505c1d..51194e5e4 100644
--- a/src/Views/Traits/Helpers/BooleanColumnHelpers.php
+++ b/src/Views/Columns/Traits/Helpers/BooleanColumnHelpers.php
@@ -1,6 +1,6 @@
component;
- }
-
public function hasFrom(): bool
{
return $this->from !== null;
@@ -32,11 +24,6 @@ public function getTitle(): string
return $this->title;
}
- public function getSlug(): string
- {
- return Str::slug($this->hasCustomSlug() ? $this->getCustomSlug() : $this->getTitle());
- }
-
public function getField(): ?string
{
return $this->field;
@@ -57,11 +44,6 @@ public function isColumnBySelectName(string $name): bool
return $this->getColumnSelectName() === $name;
}
- public function isColumnBySlug(string $slug): bool
- {
- return $this->getSlug() === $slug;
- }
-
public function hasField(): bool
{
return $this->getField() !== null;
@@ -139,32 +121,6 @@ public function getValue(Model $row): mixed
return $row->{$this->getRelationString().'.'.$this->getField()};
}
- public function eagerLoadRelationsIsEnabled(): bool
- {
- return $this->eagerLoadRelations === true;
- }
-
- public function isReorderColumn(): bool
- {
- return $this->isReorderColumn;
- }
-
- public function hasFormatter(): bool
- {
- return $this->formatCallback !== null;
- }
-
- public function getFormatCallback(): ?callable
- {
- return $this->formatCallback;
- }
-
- // TODO
- public function getLabelCallback(): ?callable
- {
- return $this->labelCallback;
- }
-
public function isHtml(): bool
{
return $this->html === true;
@@ -183,38 +139,6 @@ public function view(string $view): self
return $this;
}
- public function isClickable(): bool
- {
- return $this->clickable &&
- $this->getHasTableRowUrl() &&
- ! $this instanceof LinkColumn;
- }
-
- public function getCustomSlug(): string
- {
- return $this->customSlug;
- }
-
- public function hasCustomSlug(): bool
- {
- return $this->customSlug !== null;
- }
-
- public function getColumnLabelStatus(): bool
- {
- return $this->displayColumnLabel ?? true;
- }
-
- public function getHasTableRowUrl(): bool
- {
- return $this->hasTableRowUrl;
- }
-
- public function getIsReorderColumn(): bool
- {
- return $this->isReorderColumn;
- }
-
public function getColumnIndex(): int
{
return $this->columnIndex;
diff --git a/src/Views/Columns/Traits/Helpers/ComponentColumnHelpers.php b/src/Views/Columns/Traits/Helpers/ComponentColumnHelpers.php
new file mode 100644
index 000000000..3749b131e
--- /dev/null
+++ b/src/Views/Columns/Traits/Helpers/ComponentColumnHelpers.php
@@ -0,0 +1,5 @@
+outputFormat ?? 'Y-m-d';
- }
-
- /**
- * Retrieve the inputFormat to use for the Column
- */
- public function getInputFormat(): ?string
- {
- return $this->inputFormat ?? null;
- }
-
/**
* Retrieve the Empty Value to use for the Column
*/
diff --git a/src/Views/Traits/Helpers/IconColumnHelpers.php b/src/Views/Columns/Traits/Helpers/IconColumnHelpers.php
similarity index 71%
rename from src/Views/Traits/Helpers/IconColumnHelpers.php
rename to src/Views/Columns/Traits/Helpers/IconColumnHelpers.php
index 0b9075ed8..86170b623 100644
--- a/src/Views/Traits/Helpers/IconColumnHelpers.php
+++ b/src/Views/Columns/Traits/Helpers/IconColumnHelpers.php
@@ -1,9 +1,10 @@
livewireComponent ?? null;
+ }
+
+ /**
+ * Determines whether a Component View has been set
+ */
+ public function hasLivewireComponent(): bool
+ {
+ return isset($this->livewireComponent);
+ }
+}
diff --git a/src/Views/Traits/Helpers/ViewComponentColumnHelpers.php b/src/Views/Columns/Traits/Helpers/ViewComponentColumnHelpers.php
similarity index 78%
rename from src/Views/Traits/Helpers/ViewComponentColumnHelpers.php
rename to src/Views/Columns/Traits/Helpers/ViewComponentColumnHelpers.php
index f1c4d9bb7..0a5eb7ed8 100644
--- a/src/Views/Traits/Helpers/ViewComponentColumnHelpers.php
+++ b/src/Views/Columns/Traits/Helpers/ViewComponentColumnHelpers.php
@@ -1,6 +1,6 @@
['address', 'group']
- protected array $relations = [];
-
- protected bool $eagerLoadRelations = false;
-
- protected mixed $formatCallback = null;
-
protected bool $html = false;
- protected mixed $labelCallback = null;
-
- protected bool $clickable = true;
-
- protected ?string $customSlug = null;
-
- protected bool $hasTableRowUrl = false;
-
- protected bool $isReorderColumn = false;
-
protected ?int $columnIndex;
protected ?int $rowIndex;
diff --git a/src/Views/Columns/Traits/IsReorderColumn.php b/src/Views/Columns/Traits/IsReorderColumn.php
new file mode 100644
index 000000000..36cea5d32
--- /dev/null
+++ b/src/Views/Columns/Traits/IsReorderColumn.php
@@ -0,0 +1,25 @@
+isReorderColumn;
+ }
+
+ public function getIsReorderColumn(): bool
+ {
+ return $this->isReorderColumn;
+ }
+
+ public function setIsReorderColumn(bool $isReorderColumn): self
+ {
+ $this->isReorderColumn = $isReorderColumn;
+
+ return $this;
+ }
+}
diff --git a/src/Views/Traits/Columns/IsSearchable.php b/src/Views/Columns/Traits/IsSearchable.php
similarity index 90%
rename from src/Views/Traits/Columns/IsSearchable.php
rename to src/Views/Columns/Traits/IsSearchable.php
index 69801c16c..200e63c96 100644
--- a/src/Views/Traits/Columns/IsSearchable.php
+++ b/src/Views/Columns/Traits/IsSearchable.php
@@ -1,6 +1,6 @@
isLabel()) {
throw new DataTableConfigurationException('You can not use a label column with a component column');
diff --git a/src/Views/Columns/WireLinkColumn.php b/src/Views/Columns/WireLinkColumn.php
index 6d9ba9a0c..67ccb1a0e 100644
--- a/src/Views/Columns/WireLinkColumn.php
+++ b/src/Views/Columns/WireLinkColumn.php
@@ -5,9 +5,9 @@
use Illuminate\Database\Eloquent\Model;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\WireLinkColumnConfiguration;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasActionCallback, HasConfirmation, HasTitleCallback};
-use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\WireLinkColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\WireLinkColumnConfiguration;
+use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\WireLinkColumnHelpers;
+use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasActionCallback,HasConfirmation, HasTitleCallback};
class WireLinkColumn extends Column
{
@@ -36,8 +36,10 @@ public function getContents(Model $row): null|string|\Illuminate\Support\HtmlStr
throw new DataTableConfigurationException('You must specify an action callback for a WireLink column.');
}
- return $this->getColumnViewWithDefaults()
+ return view($this->getView())
->withColumn($this)
+ ->withIsTailwind($this->isTailwind())
+ ->withIsBootstrap($this->isBootstrap())
->withTitle(app()->call($this->getTitleCallback(), ['row' => $row]))
->withPath(app()->call($this->getActionCallback(), ['row' => $row]))
->withAttributes($this->hasAttributesCallback() ? app()->call($this->getAttributesCallback(), ['row' => $row]) : []);
diff --git a/src/Views/Traits/Configuration/ColumnConfiguration.php b/src/Views/Traits/Configuration/ColumnConfiguration.php
deleted file mode 100644
index 0115e74fe..000000000
--- a/src/Views/Traits/Configuration/ColumnConfiguration.php
+++ /dev/null
@@ -1,122 +0,0 @@
-component = $component;
-
- return $this;
- }
-
- public function label(callable $callback): self
- {
- $this->from = null;
- $this->field = null;
- $this->labelCallback = $callback;
-
- return $this;
- }
-
- public function format(callable $callable): Column
- {
- $this->formatCallback = $callable;
-
- return $this;
- }
-
- public function html(): self
- {
- $this->html = true;
-
- return $this;
- }
-
- public function setTable(string $table): self
- {
- $this->table = $table;
-
- return $this;
- }
-
- public function eagerLoadRelations(): self
- {
- $this->eagerLoadRelations = true;
-
- return $this;
- }
-
- public function unclickable(): self
- {
- $this->clickable = false;
-
- return $this;
- }
-
- public function setCustomSlug(string $customSlug): self
- {
- $this->customSlug = $customSlug;
-
- return $this;
- }
-
- public function setColumnLabelStatusDisabled(): self
- {
- $this->setColumnLabelStatus(false);
-
- return $this;
- }
-
- public function setColumnLabelStatusEnabled(): self
- {
- $this->setColumnLabelStatus(true);
-
- return $this;
- }
-
- public function setColumnLabelStatus(bool $status): void
- {
- $this->displayColumnLabel = $status;
- }
-
- public function setHasTableRowUrl(bool $hasTableRowUrl): self
- {
- $this->hasTableRowUrl = $hasTableRowUrl;
-
- return $this;
- }
-
- public function setIsReorderColumn(bool $isReorderColumn): self
- {
- $this->isReorderColumn = $isReorderColumn;
-
- return $this;
- }
-
- public function setIndexes(int $rowIndex, int $columnIndex): self
- {
- $this->setRowIndex($rowIndex);
- $this->setColumnIndex($columnIndex);
-
- return $this;
- }
-
- public function setColumnIndex(int $columnIndex): self
- {
- $this->columnIndex = $columnIndex;
-
- return $this;
- }
-
- public function setRowIndex(int $rowIndex): self
- {
- $this->rowIndex = $rowIndex;
-
- return $this;
- }
-}
diff --git a/src/Views/Traits/Configuration/ImageColumnConfiguration.php b/src/Views/Traits/Configuration/ImageColumnConfiguration.php
deleted file mode 100644
index 8ab662b87..000000000
--- a/src/Views/Traits/Configuration/ImageColumnConfiguration.php
+++ /dev/null
@@ -1,5 +0,0 @@
-separator !== null && is_string($this->separator);
- }
-
- public function getSeparator(): string
- {
- return $this->separator;
- }
-
- public function getEmptyValue(): string
- {
- return $this->emptyValue;
- }
-
- public function hasDataCallback(): bool
- {
- return isset($this->dataCallback) && is_callable($this->dataCallback);
- }
-
- public function getDataCallback(): ?callable
- {
- return $this->dataCallback;
- }
-
- public function hasOutputFormatCallback(): bool
- {
- return isset($this->outputFormat) && is_callable($this->outputFormat);
- }
-
- public function getOutputFormatCallback(): ?callable
- {
- return $this->outputFormat;
- }
-
- public function getContents(Model $row): null|string|\BackedEnum|HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
- {
- $outputValues = [];
- $value = $this->getValue($row);
-
- if (! $this->hasDataCallback()) {
- throw new DataTableConfigurationException('You must set a data() method on an ArrayColumn');
- }
-
- if (! $this->hasOutputFormatCallback()) {
- throw new DataTableConfigurationException('You must set an outputFormat() method on an ArrayColumn');
- }
-
- foreach (call_user_func($this->getDataCallback(), $value, $row) as $i => $v) {
- $outputValues[] = call_user_func($this->getOutputFormatCallback(), $i, $v);
- }
-
- return new HtmlString((! empty($outputValues) ? implode($this->getSeparator(), $outputValues) : $this->getEmptyValue()));
- }
-}
diff --git a/src/Views/Traits/Helpers/ImageColumnHelpers.php b/src/Views/Traits/Helpers/ImageColumnHelpers.php
deleted file mode 100644
index 2226586a1..000000000
--- a/src/Views/Traits/Helpers/ImageColumnHelpers.php
+++ /dev/null
@@ -1,5 +0,0 @@
-livewireComponent ?? null;
- }
-
- /**
- * Determines whether a Component View has been set
- */
- public function hasLivewireComponent(): bool
- {
- return isset($this->livewireComponent);
- }
-
- public function getContents(Model $row): null|string|HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
- {
- if (! $this->hasLivewireComponent()) {
- throw new DataTableConfigurationException('You must define a Livewire Component for this column');
- }
-
- if ($this->isLabel()) {
- throw new DataTableConfigurationException('You can not use a label column with a Livewire Component column');
- }
-
- $attributes = [];
- $value = $this->getValue($row);
-
- if ($this->hasAttributesCallback()) {
- $attributes = call_user_func($this->getAttributesCallback(), $value, $row, $this);
-
- if (! is_array($attributes)) {
- throw new DataTableConfigurationException('The return type of callback must be an array');
- }
- }
-
- $implodedAttributes = collect($attributes)->map(function ($value, $key) {
- return ':'.$key.'="$'.$key.'"';
- })->implode(' ');
-
- return new HtmlString(Blade::render(
- '',
- [
- 'component' => $this->getLivewireComponent(),
- ...$attributes,
- ],
- ));
-
- }
-}
diff --git a/src/Views/Traits/Helpers/WireLinkColumnHelpers.php b/src/Views/Traits/Helpers/WireLinkColumnHelpers.php
deleted file mode 100644
index f24c7e460..000000000
--- a/src/Views/Traits/Helpers/WireLinkColumnHelpers.php
+++ /dev/null
@@ -1,5 +0,0 @@
-assertSame('Array Col', $column->getTitle());
+ parent::setUp();
+ self::$columnInstance = ArrayColumn::make('Name');
}
public function test_can_set_the_separator(): void
{
- $column = ArrayColumn::make('Array Col');
-
- $this->assertSame(' ', $column->getSeparator());
- $column->separator('
');
- $this->assertTrue($column->hasSeparator());
+ $this->assertSame(' ', self::$columnInstance->getSeparator());
+ self::$columnInstance->separator('
');
+ $this->assertTrue(self::$columnInstance->hasSeparator());
- $this->assertSame('
', $column->getSeparator());
+ $this->assertSame('
', self::$columnInstance->getSeparator());
}
public function test_can_set_the_output_format(): void
{
- $column = ArrayColumn::make('Array Col');
-
- $this->assertNull($column->getOutputFormatCallback());
- $this->assertFalse($column->hasOutputFormatCallback());
- $column->outputFormat(fn ($index, $value) => "".$value->name.'');
- $this->assertTrue($column->hasOutputFormatCallback());
+ $this->assertNull(self::$columnInstance->getOutputFormatCallback());
+ $this->assertFalse(self::$columnInstance->hasOutputFormatCallback());
+ self::$columnInstance->outputFormat(fn ($index, $value) => "".$value->name.'');
+ $this->assertTrue(self::$columnInstance->hasOutputFormatCallback());
}
public function test_requires_the_data_callback(): void
@@ -50,38 +46,38 @@ public function test_requires_the_data_callback(): void
public function test_can_get_the_output_format_callback(): void
{
$this->expectException(DataTableConfigurationException::class);
- $column = ArrayColumn::make('Average Age')
+ self::$columnInstance
->separator('
')
->data(fn ($value, $row) => ($row->pets))
->sortable();
- $this->assertNotNull($column->getDataCallback());
+ $this->assertNotNull(self::$columnInstance->getDataCallback());
- $contents = $column->getContents(Pet::find(1));
+ $contents = self::$columnInstance->getContents(Pet::find(1));
$this->assertNull($contents);
}
public function test_requires_the_output_format_callback(): void
{
$this->expectException(DataTableConfigurationException::class);
- $column = ArrayColumn::make('Average Age')
+ self::$columnInstance
->separator('
')
->data(fn ($value, $row) => ($row->pets))
->sortable();
- $contents = $column->getContents(Pet::find(1));
+ $contents = self::$columnInstance->getContents(Pet::find(1));
$this->assertNull($contents);
}
public function test_can_get_empty_value(): void
{
- $column = ArrayColumn::make('Average Age')
+ self::$columnInstance
->separator('
')
->data(fn ($value, $row) => ($row->pets))
->sortable();
- $this->assertSame('', $column->getEmptyValue());
- $column->emptyValue('Unknown');
- $this->assertSame('Unknown', $column->getEmptyValue());
+ $this->assertSame('', self::$columnInstance->getEmptyValue());
+ self::$columnInstance->emptyValue('Unknown');
+ $this->assertSame('Unknown', self::$columnInstance->getEmptyValue());
}
}
diff --git a/tests/Unit/Views/Columns/AvgColumnTest.php b/tests/Unit/Views/Columns/AvgColumnTest.php
index b247c11cc..1a7d179a4 100644
--- a/tests/Unit/Views/Columns/AvgColumnTest.php
+++ b/tests/Unit/Views/Columns/AvgColumnTest.php
@@ -3,35 +3,31 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
use PHPUnit\Framework\Attributes\DataProviderExternal;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Tests\Unit\Attributes\AggregateColumnProvider;
use Rappasoft\LaravelLivewireTables\Views\Columns\AvgColumn;
-final class AvgColumnTest extends TestCase
+#[Group('Columns')]
+final class AvgColumnTest extends ColumnTestCase
{
protected function setUp(): void
{
parent::setUp();
- parent::setupSpeciesTable();
- }
+ self::$columnInstance = AvgColumn::make('Name');
- public function test_can_set_the_column_title(): void
- {
- $column = AvgColumn::make('Average Age');
-
- $this->assertSame('Average Age', $column->getTitle());
+ parent::setupSpeciesTable();
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_setup_column_correctly(string $relation_name, string $foreign_field): void
{
- $column = AvgColumn::make('Average Age')
+ self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
- $this->assertNotEmpty($column);
+ $this->assertNotEmpty(self::$columnInstance);
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
@@ -39,79 +35,79 @@ public function test_can_not_skip_set_data_source(string $relation_name, string
{
$this->expectException(DataTableConfigurationException::class);
- $column = AvgColumn::make('Average Age')
+ self::$columnInstance
->sortable();
- $contents = $column->getContents(Pet::find(1));
- $this->assertNull($contents);
+ $contents = self::$columnInstance->getContents(Pet::find(1));
+ $this->assertNull(self::$columnInstance);
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_get_data_source(string $relation_name, string $foreign_field): void
{
- $column = AvgColumn::make('Average Age')
+ self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
- $this->assertTrue($column->hasDataSource());
- $this->assertSame($relation_name, $column->getDataSource());
+ $this->assertTrue(self::$columnInstance->hasDataSource());
+ $this->assertSame($relation_name, self::$columnInstance->getDataSource());
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_get_foreign_column(string $relation_name, string $foreign_field): void
{
- $column = AvgColumn::make('Average Age')
+ self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
- $this->assertTrue($column->hasForeignColumn());
- $this->assertSame($foreign_field, $column->getForeignColumn());
+ $this->assertTrue(self::$columnInstance->hasForeignColumn());
+ $this->assertSame($foreign_field, self::$columnInstance->getForeignColumn());
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_set_foreign_column(string $relation_name, string $foreign_field): void
{
- $column = AvgColumn::make('Average Age')
+ self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
- $this->assertTrue($column->hasForeignColumn());
- $this->assertSame($foreign_field, $column->getForeignColumn());
- $column->setForeignColumn('test');
- $this->assertTrue($column->hasForeignColumn());
- $this->assertSame('test', $column->getForeignColumn());
+ $this->assertTrue(self::$columnInstance->hasForeignColumn());
+ $this->assertSame($foreign_field, self::$columnInstance->getForeignColumn());
+ self::$columnInstance->setForeignColumn('test');
+ $this->assertTrue(self::$columnInstance->hasForeignColumn());
+ $this->assertSame('test', self::$columnInstance->getForeignColumn());
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_get_data_source_fields(string $relation_name, string $foreign_field): void
{
- $column = AvgColumn::make('Average Age')
+ self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
- $this->assertTrue($column->hasDataSource());
- $this->assertSame($relation_name, $column->getDataSource());
- $this->assertTrue($column->hasForeignColumn());
- $this->assertSame($foreign_field, $column->getForeignColumn());
+ $this->assertTrue(self::$columnInstance->hasDataSource());
+ $this->assertSame($relation_name, self::$columnInstance->getDataSource());
+ $this->assertTrue(self::$columnInstance->hasForeignColumn());
+ $this->assertSame($foreign_field, self::$columnInstance->getForeignColumn());
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_get_aggregate_method(string $relation_name, string $foreign_field): void
{
- $column = AvgColumn::make('Average Age')
+ self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
- $this->assertSame('avg', $column->getAggregateMethod());
- $column->setAggregateMethod('test_avg');
- $this->assertSame('test_avg', $column->getAggregateMethod());
+ $this->assertSame('avg', self::$columnInstance->getAggregateMethod());
+ self::$columnInstance->setAggregateMethod('test_avg');
+ $this->assertSame('test_avg', self::$columnInstance->getAggregateMethod());
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_renders_correctly(string $relation_name, string $foreign_field): void
{
$rows = $this->speciesTable->getRows();
- $column = AvgColumn::make('Average Age')
+ self::$columnInstance
->setDataSource('pets', 'age');
- $contents = $column->getContents($rows->first());
+ $contents = self::$columnInstance->getContents($rows->first());
$this->assertSame('15', $contents);
- $contents = $column->getContents($rows[2]);
+ $contents = self::$columnInstance->getContents($rows[2]);
$this->assertSame('6', $contents);
}
}
diff --git a/tests/Unit/Views/Columns/BooleanColumnTest.php b/tests/Unit/Views/Columns/BooleanColumnTest.php
index e2a8c242b..a4da99d2d 100644
--- a/tests/Unit/Views/Columns/BooleanColumnTest.php
+++ b/tests/Unit/Views/Columns/BooleanColumnTest.php
@@ -2,17 +2,17 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\BooleanColumn;
-final class BooleanColumnTest extends TestCase
+#[Group('Columns')]
+final class BooleanColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = BooleanColumn::make('Name', 'name');
-
- $this->assertSame('Name', $column->getTitle());
+ parent::setUp();
+ self::$columnInstance = BooleanColumn::make('Name', 'name');
}
public function test_can_render_field(): void
@@ -82,28 +82,27 @@ public function test_can_set_toggleable(): void
{
$column = BooleanColumn::make('Name', 'name');
- $this->assertFalse($column->getIsToggleable());
- $this->assertNull($column->getToggleMethod());
- $column->toggleable('changeStatus');
- $this->assertTrue($column->getIsToggleable());
- $this->assertSame('changeStatus', $column->getToggleMethod());
+ $this->assertFalse(self::$columnInstance->getIsToggleable());
+ $this->assertNull(self::$columnInstance->getToggleMethod());
+ self::$columnInstance->toggleable('changeStatus');
+ $this->assertTrue(self::$columnInstance->getIsToggleable());
+ $this->assertSame('changeStatus', self::$columnInstance->getToggleMethod());
}
public function test_can_set_toggleable_with_confirm_message(): void
{
- $column = BooleanColumn::make('Name', 'name')
- ->toggleable('changeStatus');
+ self::$columnInstance->toggleable('changeStatus');
- $this->assertTrue($column->getIsToggleable());
- $this->assertSame('changeStatus', $column->getToggleMethod());
+ $this->assertTrue(self::$columnInstance->getIsToggleable());
+ $this->assertSame('changeStatus', self::$columnInstance->getToggleMethod());
- $this->assertFalse($column->hasConfirmMessage());
+ $this->assertFalse(self::$columnInstance->hasConfirmMessage());
- $column->confirmMessage('Are you sure?');
+ self::$columnInstance->confirmMessage('Are you sure?');
- $this->assertTrue($column->hasConfirmMessage());
+ $this->assertTrue(self::$columnInstance->hasConfirmMessage());
- $this->assertSame('Are you sure?', $column->getConfirmMessage());
+ $this->assertSame('Are you sure?', self::$columnInstance->getConfirmMessage());
}
public function test_can_get_value(): void
diff --git a/tests/Unit/Views/Columns/ButtonGroupColumnTest.php b/tests/Unit/Views/Columns/ButtonGroupColumnTest.php
index cab4bdb4f..0e23ad6f4 100644
--- a/tests/Unit/Views/Columns/ButtonGroupColumnTest.php
+++ b/tests/Unit/Views/Columns/ButtonGroupColumnTest.php
@@ -2,17 +2,17 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\ButtonGroupColumn;
-final class ButtonGroupColumnTest extends TestCase
+#[Group('Columns')]
+final class ButtonGroupColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = ButtonGroupColumn::make('Name', 'name');
-
- $this->assertSame('Name', $column->getTitle());
+ parent::setUp();
+ self::$columnInstance = ButtonGroupColumn::make('Name', 'name');
}
public function test_can_render_field(): void
diff --git a/tests/Unit/Views/Columns/ColorColumnTest.php b/tests/Unit/Views/Columns/ColorColumnTest.php
index 3b784919e..1445c3d1c 100644
--- a/tests/Unit/Views/Columns/ColorColumnTest.php
+++ b/tests/Unit/Views/Columns/ColorColumnTest.php
@@ -2,25 +2,28 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Views\Columns\ColorColumn;
-final class ColorColumnTest extends TestCase
+#[Group('Columns')]
+final class ColorColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
+ parent::setUp();
+ self::$columnInstance = ColorColumn::make('Favorite Color', 'favorite_color');
+ }
- $this->assertSame('Favorite Color', $column->getTitle());
+ public function test_can_set_the_column_title(): void
+ {
+ $this->assertSame('Favorite Color', self::$columnInstance->getTitle());
}
public function test_can_get_the_column_view(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
-
- $this->assertSame('livewire-tables::includes.columns.color', $column->getView());
- $column->setView('test-color-column');
- $this->assertSame('test-color-column', $column->getView());
+ $this->assertSame('livewire-tables::includes.columns.color', self::$columnInstance->getView());
+ self::$columnInstance->setView('test-color-column');
+ $this->assertSame('test-color-column', self::$columnInstance->getView());
}
@@ -33,38 +36,31 @@ public function test_can_infer_field_name_from_title_if_no_from(): void
public function test_can_set_base_field_from_from(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
-
- $this->assertSame('favorite_color', $column->getField());
+ $this->assertSame('favorite_color', self::$columnInstance->getField());
}
public function test_can_set_view(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
-
- $this->assertSame('livewire-tables::includes.columns.color', $column->getView());
+ $this->assertSame('livewire-tables::includes.columns.color', self::$columnInstance->getView());
}
public function test_can_set_default_value(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color')->defaultValue('#FEFEFE');
+ self::$columnInstance->defaultValue('#FEFEFE');
- $this->assertSame('#FEFEFE', $column->getDefaultValue());
+ $this->assertSame('#FEFEFE', self::$columnInstance->getDefaultValue());
}
public function test_can_set_relation_field_from_from(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
-
- $this->assertSame('favorite_color', $column->getField());
+ $this->assertSame('favorite_color', self::$columnInstance->getField());
}
public function test_can_check_color_callback_presence(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
- $this->assertFalse($column->hasColorCallback());
+ $this->assertFalse(self::$columnInstance->hasColorCallback());
- $column->color(
+ self::$columnInstance->color(
function ($row) {
if ($row->species_id == 1) {
return '#ff0000';
@@ -76,58 +72,54 @@ function ($row) {
}
);
- $this->assertTrue($column->hasColorCallback());
+ $this->assertTrue(self::$columnInstance->hasColorCallback());
}
public function test_can_check_attribute_callback_presence(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
- $this->assertFalse($column->hasAttributesCallback());
+ $this->assertFalse(self::$columnInstance->hasAttributesCallback());
}
public function test_can_set_attribute_callback(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
- $this->assertFalse($column->hasAttributesCallback());
+ $this->assertFalse(self::$columnInstance->hasAttributesCallback());
- $column->attributes(function ($row) {
+ self::$columnInstance->attributes(function ($row) {
return [
'class' => '!rounded-lg self-center',
'default' => true,
];
});
- $this->assertTrue($column->hasAttributesCallback());
+ $this->assertTrue(self::$columnInstance->hasAttributesCallback());
}
public function test_can_get_attribute_callback(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color')->attributes(function ($row) {
+ self::$columnInstance->attributes(function ($row) {
return [
'class' => '!rounded-lg self-center',
'default' => true,
];
});
$rows = $this->basicTable->setAdditionalSelects(['pets.favorite_color as favorite_color'])->getRows();
- $this->assertSame(['class' => '!rounded-lg self-center', 'default' => true], $column->getAttributeBag($rows->first())->getAttributes());
+ $this->assertSame(['class' => '!rounded-lg self-center', 'default' => true], self::$columnInstance->getAttributeBag($rows->first())->getAttributes());
}
public function test_can_get_column_formatted_contents(): void
{
- $column = ColorColumn::make('Favorite Color', 'favorite_color');
-
$rows = $this->basicTable->setAdditionalSelects(['pets.favorite_color as favorite_color'])->getRows();
- $this->assertSame($rows->first()->favorite_color, $column->getValue($rows->first()));
- $this->assertSame($rows->first()->favorite_color, $column->getColor($rows->first()));
+ $this->assertSame($rows->first()->favorite_color, self::$columnInstance->getValue($rows->first()));
+ $this->assertSame($rows->first()->favorite_color, self::$columnInstance->getColor($rows->first()));
- $this->assertSame($rows->last()->favorite_color, $column->getColor($rows->last()));
- $this->assertSame($rows->last()->favorite_color, $column->getValue($rows->last()));
+ $this->assertSame($rows->last()->favorite_color, self::$columnInstance->getColor($rows->last()));
+ $this->assertSame($rows->last()->favorite_color, self::$columnInstance->getValue($rows->last()));
$currentRow = $rows->slice(2, 1)->first();
- $this->assertSame($currentRow->favorite_color, $column->getValue($currentRow));
- $this->assertSame($currentRow->favorite_color, $column->getColor($currentRow));
+ $this->assertSame($currentRow->favorite_color, self::$columnInstance->getValue($currentRow));
+ $this->assertSame($currentRow->favorite_color, self::$columnInstance->getColor($currentRow));
}
public function test_can_get_column_contents_from_color(): void
diff --git a/tests/Unit/Views/Columns/ColumnTestCase.php b/tests/Unit/Views/Columns/ColumnTestCase.php
new file mode 100644
index 000000000..f9ac7cf8f
--- /dev/null
+++ b/tests/Unit/Views/Columns/ColumnTestCase.php
@@ -0,0 +1,56 @@
+assertSame('Name', self::$columnInstance->getTitle());
+ }
+
+ public function test_can_set_the_column_component(): void
+ {
+ $this->assertFalse(self::$columnInstance->hasComponent());
+
+ self::$columnInstance->setComponent($this->basicTable);
+
+ $this->assertTrue(self::$columnInstance->hasComponent());
+
+ $this->assertSame($this->basicTable, self::$columnInstance->getComponent());
+ }
+
+ public function test_can_check_if_is_reorder_column(): void
+ {
+ $this->assertFalse(self::$columnInstance->isReorderColumn());
+
+ }
+
+ public function test_can_get_sorting_pills_direction_deprecated(): void
+ {
+ $this->assertSame('A-Z', self::$columnInstance->getSortingPillDirection($this->basicTable, 'asc'));
+ $this->assertSame('Z-A', self::$columnInstance->getSortingPillDirection($this->basicTable, 'desc'));
+
+ self::$columnInstance->setSortingPillDirections('1-2', '2-1');
+ $this->assertSame('1-2', self::$columnInstance->getSortingPillDirection($this->basicTable, 'asc'));
+ $this->assertSame('2-1', self::$columnInstance->getSortingPillDirection($this->basicTable, 'desc'));
+
+ }
+}
diff --git a/tests/Unit/Views/Columns/ComponentColumnTest.php b/tests/Unit/Views/Columns/ComponentColumnTest.php
index bded51dc5..f87a663d3 100644
--- a/tests/Unit/Views/Columns/ComponentColumnTest.php
+++ b/tests/Unit/Views/Columns/ComponentColumnTest.php
@@ -3,25 +3,20 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
use Illuminate\Support\Facades\Blade;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Components\TestComponent;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Columns\ComponentColumn;
-final class ComponentColumnTest extends TestCase
+#[Group('Columns')]
+final class ComponentColumnTest extends ColumnTestCase
{
protected function setUp(): void
{
parent::setUp();
- }
-
- public function test_can_set_the_column_title(): void
- {
- $column = ComponentColumn::make('Name', 'name');
-
- $this->assertSame('Name', $column->getTitle());
+ self::$columnInstance = ComponentColumn::make('Name', 'name');
}
public function test_can_not_set_component_column_as_label(): void
@@ -36,7 +31,7 @@ public function test_can_not_set_component_column_as_label(): void
public function test_can_not_be_both_collapsible_on_mobile_and_on_tablet(): void
{
$this->expectException(DataTableConfigurationException::class);
- $column = ComponentColumn::make('Name', 'name')->collapseOnMobile()->collapseOnTablet();
+ $column = self::$columnInstance->collapseOnMobile()->collapseOnTablet();
$row = Pet::find(1);
$column->getContents($row);
@@ -63,7 +58,7 @@ public function test_can_get_custom_slot(): void
'age' => $row->age,
])
->slot(fn ($value, $row, Column $column) => (($row->age < 10) ? 'youngslot' : 'oldslot'))
- ->component('livewire-tables-test::test');
+ ->component('test-component');
$pet1 = Pet::where('age', '>', 11)->first();
$pet1_contents = $column->getContents($pet1);
@@ -83,7 +78,7 @@ public function test_can_get_attributes(): void
'age' => $row->age,
])
->slot(fn ($value, $row, Column $column) => (($row->age < 10) ? 'youngslot' : 'oldslot'))
- ->component('livewire-tables-test::test');
+ ->component('test-component');
$pet1 = Pet::where('age', '>', 11)->first();
$pet1_contents = $column->getContents($pet1);
@@ -94,4 +89,18 @@ public function test_can_get_attributes(): void
$this->assertSame(2, $pet2_contents->getData()['attributes']['age']);
}
+
+ public function test_can_not_return_invalid_attributes_return(): void
+ {
+ $this->expectException(DataTableConfigurationException::class);
+
+ $column = ComponentColumn::make('Total Users')
+ ->component('test-component')
+ ->attributes(fn ($value, $row, Column $column) => (string) 'test');
+
+ $contents = $column->getContents(Pet::find(1));
+
+ $this->assertSame('2420 ', $contents);
+
+ }
}
diff --git a/tests/Unit/Views/Columns/CountColumnTest.php b/tests/Unit/Views/Columns/CountColumnTest.php
index 6890232ef..10afd9eab 100644
--- a/tests/Unit/Views/Columns/CountColumnTest.php
+++ b/tests/Unit/Views/Columns/CountColumnTest.php
@@ -2,29 +2,30 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\CountColumn;
-final class CountColumnTest extends TestCase
+#[Group('Columns')]
+final class CountColumnTest extends ColumnTestCase
{
protected function setUp(): void
{
parent::setUp();
parent::setupSpeciesTable();
+ self::$columnInstance = CountColumn::make('Total Users');
+
}
public function test_can_set_the_column_title(): void
{
- $column = CountColumn::make('Total Users');
-
- $this->assertSame('Total Users', $column->getTitle());
+ $this->assertSame('Total Users', self::$columnInstance->getTitle());
}
public function test_can_setup_column_correctly(): void
{
- $column = CountColumn::make('Total Users')
+ $column = self::$columnInstance
->setDataSource('users')
->sortable();
@@ -35,7 +36,7 @@ public function test_can_not_skip_set_data_source(): void
{
$this->expectException(DataTableConfigurationException::class);
- $column = CountColumn::make('Average Age')
+ $column = self::$columnInstance
->sortable();
$contents = $column->getContents(Pet::find(1));
$this->assertNull($contents);
@@ -46,7 +47,7 @@ public function test_renders_correctly(): void
{
$rows = $this->speciesTable->getRows();
$row1 = $rows->first();
- $column = CountColumn::make('Pets')
+ $column = self::$columnInstance
->setDataSource('pets');
$contents = $column->getContents($rows->first());
$this->assertSame('2', $contents);
diff --git a/tests/Unit/Views/Columns/DateColumnTest.php b/tests/Unit/Views/Columns/DateColumnTest.php
index 876bb9bda..9cc947edf 100644
--- a/tests/Unit/Views/Columns/DateColumnTest.php
+++ b/tests/Unit/Views/Columns/DateColumnTest.php
@@ -2,24 +2,24 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
// use Illuminate\Support\Facades\Exceptions;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\DateColumn;
-final class DateColumnTest extends TestCase
+#[Group('Columns')]
+final class DateColumnTest extends ColumnTestCase
{
protected function setUp(): void
{
parent::setUp();
parent::setupPetOwnerTable();
+ self::$columnInstance = DateColumn::make('Last Visit', 'last_visit');
}
public function test_can_set_the_column_title(): void
{
- $column = DateColumn::make('Last Visit', 'last_visit');
-
- $this->assertSame('Last Visit', $column->getTitle());
+ $this->assertSame('Last Visit', self::$columnInstance->getTitle());
}
public function test_can_infer_field_name_from_title_if_no_from(): void
@@ -31,21 +31,17 @@ public function test_can_infer_field_name_from_title_if_no_from(): void
public function test_can_set_base_field_from_from(): void
{
- $column = DateColumn::make('Name', 'last_visit');
-
- $this->assertSame('last_visit', $column->getField());
+ $this->assertSame('last_visit', self::$columnInstance->getField());
}
public function test_can_set_relation_field_from_from(): void
{
- $column = DateColumn::make('Name', 'last_visit');
-
- $this->assertSame('last_visit', $column->getField());
+ $this->assertSame('last_visit', self::$columnInstance->getField());
}
public function test_can_get_column_formatted_contents(): void
{
- $column = DateColumn::make('Name', 'last_visit')->inputFormat('Y-m-d')->outputFormat('Y-m-d');
+ $column = self::$columnInstance->inputFormat('Y-m-d')->outputFormat('Y-m-d');
$rows = $this->basicTable->getRows();
@@ -55,7 +51,7 @@ public function test_can_get_column_formatted_contents(): void
public function test_can_get_column_reformatted_contents(): void
{
- $column = DateColumn::make('Name', 'last_visit')->inputFormat('Y-m-d')->outputFormat('d-m-Y');
+ $column = self::$columnInstance->inputFormat('Y-m-d')->outputFormat('d-m-Y');
$rows = $this->basicTable->getRows();
@@ -64,7 +60,7 @@ public function test_can_get_column_reformatted_contents(): void
public function test_can_not_get_column_reformatted_contents_with_bad_values(): void
{
- $column = DateColumn::make('Name', 'last_visit')->inputFormat('d-m-Y')->outputFormat('d-m-Y');
+ $column = self::$columnInstance->inputFormat('d-m-Y')->outputFormat('d-m-Y');
$column->emptyValue('Not Found');
$firstRow = $this->basicTable->getRows()->first();
@@ -93,7 +89,7 @@ public function test_can_not_get_column_reformatted_contents_with_bad_values():
public function test_can_set_column_empty_value(): void
{
- $column = DateColumn::make('Name', 'last_visit')->inputFormat('d-m-Y')->outputFormat('d-m-Y');
+ $column = self::$columnInstance->inputFormat('d-m-Y')->outputFormat('d-m-Y');
$this->assertSame('', $column->getEmptyValue());
$column->emptyValue('Not Found');
diff --git a/tests/Unit/Views/Columns/IconColumnTest.php b/tests/Unit/Views/Columns/IconColumnTest.php
index a6a609939..876f097db 100644
--- a/tests/Unit/Views/Columns/IconColumnTest.php
+++ b/tests/Unit/Views/Columns/IconColumnTest.php
@@ -2,27 +2,30 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
// use Illuminate\Support\Facades\Exceptions;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\IconColumn;
-final class IconColumnTest extends TestCase
+#[Group('Columns')]
+final class IconColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = IconColumn::make('Icon Column 1', 'favorite_color');
+ parent::setUp();
+ self::$columnInstance = IconColumn::make('Icon Column 1', 'favorite_color');
+ }
- $this->assertSame('Icon Column 1', $column->getTitle());
+ public function test_can_set_the_column_title(): void
+ {
+ $this->assertSame('Icon Column 1', self::$columnInstance->getTitle());
}
public function test_can_get_the_column_view(): void
{
- $column = IconColumn::make('Icon Column 1', 'favorite_color');
-
- $this->assertSame('livewire-tables::includes.columns.icon', $column->getView());
- $column->setView('test-icon-column');
- $this->assertSame('test-icon-column', $column->getView());
+ $this->assertSame('livewire-tables::includes.columns.icon', self::$columnInstance->getView());
+ self::$columnInstance->setView('test-icon-column');
+ $this->assertSame('test-icon-column', self::$columnInstance->getView());
}
diff --git a/tests/Unit/Views/Columns/ImageColumnTest.php b/tests/Unit/Views/Columns/ImageColumnTest.php
index af38cb2e6..51287f8ec 100644
--- a/tests/Unit/Views/Columns/ImageColumnTest.php
+++ b/tests/Unit/Views/Columns/ImageColumnTest.php
@@ -2,18 +2,18 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;
-final class ImageColumnTest extends TestCase
+#[Group('Columns')]
+final class ImageColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = ImageColumn::make('Name', 'name');
-
- $this->assertSame('Name', $column->getTitle());
+ parent::setUp();
+ self::$columnInstance = ImageColumn::make('Name', 'name');
}
public function test_can_not_infer_field_name_from_title_if_no_from(): void
diff --git a/tests/Unit/Views/Columns/IncrementColumnTest.php b/tests/Unit/Views/Columns/IncrementColumnTest.php
index 88302d164..5447a3a55 100644
--- a/tests/Unit/Views/Columns/IncrementColumnTest.php
+++ b/tests/Unit/Views/Columns/IncrementColumnTest.php
@@ -2,18 +2,18 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\IncrementColumn;
-final class IncrementColumnTest extends TestCase
+#[Group('Columns')]
+final class IncrementColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = IncrementColumn::make('Name', 'name');
-
- $this->assertSame('Name', $column->getTitle());
+ parent::setUp();
+ self::$columnInstance = IncrementColumn::make('Name', 'name');
}
public function test_can_not_infer_field_name_from_title_if_no_from(): void
diff --git a/tests/Unit/Views/Columns/LinkColumnTest.php b/tests/Unit/Views/Columns/LinkColumnTest.php
index d81948d91..54b35f602 100644
--- a/tests/Unit/Views/Columns/LinkColumnTest.php
+++ b/tests/Unit/Views/Columns/LinkColumnTest.php
@@ -2,18 +2,18 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\LinkColumn;
-final class LinkColumnTest extends TestCase
+#[Group('Columns')]
+final class LinkColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = LinkColumn::make('Name', 'name');
-
- $this->assertSame('Name', $column->getTitle());
+ parent::setUp();
+ self::$columnInstance = LinkColumn::make('Name', 'name');
}
public function test_can_not_infer_field_name_from_title_if_no_from(): void
@@ -46,7 +46,7 @@ public function test_can_render_field_if_title_and_location_callback(): void
public function test_can_check_ishtml_from_html_column(): void
{
- $column = LinkColumn::make('Name', 'name')
+ $column = self::$columnInstance
->title(fn ($row) => 'Title')
->location(fn ($row) => "#$row->id")
->html();
@@ -56,7 +56,7 @@ public function test_can_check_ishtml_from_html_column(): void
public function test_can_get_html_from_html_label_column(): void
{
- $column = LinkColumn::make('Name', 'name')
+ $column = self::$columnInstance
->title(fn ($row) => 'My Label')
->location(fn ($row) => "#$row->id")
->html();
diff --git a/tests/Unit/Views/Columns/LivewireComponentColumnTest.php b/tests/Unit/Views/Columns/LivewireComponentColumnTest.php
index eab5d9972..ac9c5b0a0 100644
--- a/tests/Unit/Views/Columns/LivewireComponentColumnTest.php
+++ b/tests/Unit/Views/Columns/LivewireComponentColumnTest.php
@@ -2,19 +2,19 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Columns\LivewireComponentColumn;
-final class LivewireComponentColumnTest extends TestCase
+#[Group('Columns')]
+final class LivewireComponentColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = LivewireComponentColumn::make('Name', 'name');
-
- $this->assertSame('Name', $column->getTitle());
+ parent::setUp();
+ self::$columnInstance = LivewireComponentColumn::make('Name', 'name');
}
public function test_can_not_be_a_label_without_component(): void
@@ -35,31 +35,28 @@ public function test_can_not_be_a_label_with_component(): void
public function test_can_add_livewire_component(): void
{
- $column = LivewireComponentColumn::make('Name', 'name');
-
- $this->assertFalse($column->hasLivewireComponent());
- $column->component('test-component');
- $this->assertTrue($column->hasLivewireComponent());
+ $this->assertFalse(self::$columnInstance->hasLivewireComponent());
+ self::$columnInstance->component('test-component');
+ $this->assertTrue(self::$columnInstance->hasLivewireComponent());
}
public function test_can_get_livewire_component(): void
{
- $column = LivewireComponentColumn::make('Name', 'name');
-
- $this->assertFalse($column->hasLivewireComponent());
- $this->assertNull($column->getLivewireComponent());
+ $this->assertFalse(self::$columnInstance->hasLivewireComponent());
+ $this->assertNull(self::$columnInstance->getLivewireComponent());
- $column->component('test-component');
+ self::$columnInstance->component('test-component');
- $this->assertTrue($column->hasLivewireComponent());
- $this->assertSame('test-component', $column->getLivewireComponent());
+ $this->assertTrue(self::$columnInstance->hasLivewireComponent());
+ $this->assertSame('test-component', self::$columnInstance->getLivewireComponent());
}
public function test_can_not_avoid_defining_livewire_component(): void
{
$this->expectException(DataTableConfigurationException::class);
+ $col = LivewireComponentColumn::make('Name');
- $contents = LivewireComponentColumn::make('Name')->getContents(Pet::find(1));
+ $contents = $col->getContents(Pet::find(1));
}
@@ -74,22 +71,22 @@ public function test_attributes_should_return_array(): void
public function test_can_check_attribute_callback_presence(): void
{
- $column = LivewireComponentColumn::make('Name', 'name')->component('test-component');
- $this->assertFalse($column->hasAttributesCallback());
+ self::$columnInstance->component('test-component');
+ $this->assertFalse(self::$columnInstance->hasAttributesCallback());
}
public function test_can_set_attribute_callback(): void
{
- $column = LivewireComponentColumn::make('Name', 'name')->component('test-component');
- $this->assertFalse($column->hasAttributesCallback());
+ self::$columnInstance->component('test-component');
+ $this->assertFalse(self::$columnInstance->hasAttributesCallback());
- $column->attributes(function ($row) {
+ self::$columnInstance->attributes(function ($row) {
return [
'class' => '!rounded-lg self-center',
'default' => true,
];
});
- $this->assertTrue($column->hasAttributesCallback());
+ $this->assertTrue(self::$columnInstance->hasAttributesCallback());
}
}
diff --git a/tests/Unit/Views/Columns/SumColumnTest.php b/tests/Unit/Views/Columns/SumColumnTest.php
index b6d618fc5..4fb0e6e0d 100644
--- a/tests/Unit/Views/Columns/SumColumnTest.php
+++ b/tests/Unit/Views/Columns/SumColumnTest.php
@@ -3,31 +3,27 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
use PHPUnit\Framework\Attributes\DataProviderExternal;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Tests\Unit\Attributes\AggregateColumnProvider;
use Rappasoft\LaravelLivewireTables\Views\Columns\SumColumn;
-final class SumColumnTest extends TestCase
+#[Group('Columns')]
+final class SumColumnTest extends ColumnTestCase
{
protected function setUp(): void
{
parent::setUp();
parent::setupSpeciesTable();
- }
-
- public function test_can_set_the_column_title(): void
- {
- $column = SumColumn::make('Sum User Age');
+ self::$columnInstance = SumColumn::make('Name');
- $this->assertSame('Sum User Age', $column->getTitle());
}
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_setup_column_correctly(string $relation_name, string $foreign_field): void
{
- $column = SumColumn::make('Sum User Age')
+ $column = self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
@@ -39,7 +35,7 @@ public function test_can_not_skip_set_data_source(string $relation_name, string
{
$this->expectException(DataTableConfigurationException::class);
- $column = SumColumn::make('Sum User Age')
+ $column = self::$columnInstance
->sortable();
$contents = $column->getContents(Pet::find(1));
$this->assertNull($contents);
@@ -49,7 +45,7 @@ public function test_can_not_skip_set_data_source(string $relation_name, string
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_set_foreign_column(string $relation_name, string $foreign_field): void
{
- $column = SumColumn::make('Sum User Age')
+ $column = self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
$this->assertTrue($column->hasForeignColumn());
@@ -63,7 +59,7 @@ public function test_can_set_foreign_column(string $relation_name, string $forei
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_get_data_source(string $relation_name, string $foreign_field): void
{
- $column = SumColumn::make('Sum User Age')
+ $column = self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
$this->assertTrue($column->hasDataSource());
@@ -73,7 +69,7 @@ public function test_can_get_data_source(string $relation_name, string $foreign_
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_get_foreign_column(string $relation_name, string $foreign_field): void
{
- $column = SumColumn::make('Sum User Age')
+ $column = self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
$this->assertTrue($column->hasForeignColumn());
@@ -83,7 +79,7 @@ public function test_can_get_foreign_column(string $relation_name, string $forei
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_get_data_source_fields(string $relation_name, string $foreign_field): void
{
- $column = SumColumn::make('Sum User Age')
+ $column = self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
$this->assertTrue($column->hasDataSource());
@@ -95,7 +91,7 @@ public function test_can_get_data_source_fields(string $relation_name, string $f
#[DataProviderExternal(AggregateColumnProvider::class, 'relationshipProvider')]
public function test_can_get_aggregate_method(string $relation_name, string $foreign_field): void
{
- $column = SumColumn::make('Sum User Age')
+ $column = self::$columnInstance
->setDataSource($relation_name, $foreign_field)
->sortable();
$this->assertSame('sum', $column->getAggregateMethod());
diff --git a/tests/Unit/Views/Columns/ViewComponentColumnTest.php b/tests/Unit/Views/Columns/ViewComponentColumnTest.php
index c5d138d71..290b15fe1 100644
--- a/tests/Unit/Views/Columns/ViewComponentColumnTest.php
+++ b/tests/Unit/Views/Columns/ViewComponentColumnTest.php
@@ -3,26 +3,21 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
use Illuminate\Support\Facades\Blade;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\TestComponent;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Columns\ViewComponentColumn;
-final class ViewComponentColumnTest extends TestCase
+#[Group('Columns')]
+final class ViewComponentColumnTest extends ColumnTestCase
{
protected function setUp(): void
{
parent::setUp();
Blade::component('test-component', TestComponent::class);
- }
-
- public function test_can_set_the_column_title(): void
- {
- $column = ViewComponentColumn::make('Total Users');
-
- $this->assertSame('Total Users', $column->getTitle());
+ self::$columnInstance = ViewComponentColumn::make('Name');
}
public function test_can_have_component_view(): void
@@ -82,14 +77,14 @@ public function test_can_not_use_as_label(): void
{
$this->expectException(DataTableConfigurationException::class);
- $column = ViewComponentColumn::make('Total Users')->label(fn () => 'My Label')->getContents(Pet::find(1));
+ self::$columnInstance->label(fn () => 'My Label')->getContents(Pet::find(1));
}
public function test_can_not_return_invalid_attributes(): void
{
$this->expectException(DataTableConfigurationException::class);
- $column = ViewComponentColumn::make('Total Users')->component('test-component')->attributes(fn ($value, $row, Column $column) => 'test')->getContents(Pet::find(1));
+ self::$columnInstance->component('test-component')->attributes(fn ($value, $row, Column $column) => 'test')->getContents(Pet::find(1));
}
}
diff --git a/tests/Unit/Views/Columns/WireLinkColumnTest.php b/tests/Unit/Views/Columns/WireLinkColumnTest.php
index e2ed87302..8ffb47654 100644
--- a/tests/Unit/Views/Columns/WireLinkColumnTest.php
+++ b/tests/Unit/Views/Columns/WireLinkColumnTest.php
@@ -2,18 +2,18 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
-use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\WireLinkColumn;
-class WireLinkColumnTest extends TestCase
+#[Group('Columns')]
+class WireLinkColumnTest extends ColumnTestCase
{
- public function test_can_set_the_column_title(): void
+ protected function setUp(): void
{
- $column = WireLinkColumn::make('Name', 'name');
-
- $this->assertSame('Name', $column->getTitle());
+ parent::setUp();
+ self::$columnInstance = WireLinkColumn::make('Name', 'name');
}
public function test_can_not_infer_field_name_from_title_if_no_from(): void
@@ -53,14 +53,12 @@ public function test_can_render_field_if_confirm_set(): void
public function test_can_add_confirm_message(): void
{
- $column = WireLinkColumn::make('Name', 'name');
-
- $this->assertFalse($column->hasConfirmMessage());
+ $this->assertFalse(self::$columnInstance->hasConfirmMessage());
- $column->confirmMessage('Test');
+ self::$columnInstance->confirmMessage('Test');
- $this->assertTrue($column->hasConfirmMessage());
+ $this->assertTrue(self::$columnInstance->hasConfirmMessage());
- $this->assertSame('Test', $column->getConfirmMessage());
+ $this->assertSame('Test', self::$columnInstance->getConfirmMessage());
}
}
diff --git a/tests/Unit/Views/Traits/Configuration/BooleanColumnConfigurationTest.php b/tests/Unit/Views/Traits/Configuration/BooleanColumnConfigurationTest.php
index 46e96fddb..48f4b6841 100644
--- a/tests/Unit/Views/Traits/Configuration/BooleanColumnConfigurationTest.php
+++ b/tests/Unit/Views/Traits/Configuration/BooleanColumnConfigurationTest.php
@@ -3,9 +3,11 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Traits\Configuration;
use Closure;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\BooleanColumn;
+#[Group('Columns')]
final class BooleanColumnConfigurationTest extends TestCase
{
public function test_boolean_column_can_set_callback(): void
diff --git a/tests/Unit/Views/Traits/Configuration/ButtonGroupColumnConfigurationTest.php b/tests/Unit/Views/Traits/Configuration/ButtonGroupColumnConfigurationTest.php
index 951e150ea..aa41ecfed 100644
--- a/tests/Unit/Views/Traits/Configuration/ButtonGroupColumnConfigurationTest.php
+++ b/tests/Unit/Views/Traits/Configuration/ButtonGroupColumnConfigurationTest.php
@@ -2,10 +2,12 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Traits\Configuration;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\ButtonGroupColumn;
use Rappasoft\LaravelLivewireTables\Views\Columns\LinkColumn;
+#[Group('Columns')]
final class ButtonGroupColumnConfigurationTest extends TestCase
{
public function test_button_group_column_can_set_buttons(): void
diff --git a/tests/Unit/Views/Traits/Configuration/ColumnConfigurationTest.php b/tests/Unit/Views/Traits/Configuration/ColumnConfigurationTest.php
index b759304fb..6910aef02 100644
--- a/tests/Unit/Views/Traits/Configuration/ColumnConfigurationTest.php
+++ b/tests/Unit/Views/Traits/Configuration/ColumnConfigurationTest.php
@@ -2,10 +2,12 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Traits\Configuration;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Filter;
+#[Group('Columns')]
final class ColumnConfigurationTest extends TestCase
{
public function test_can_set_column_to_eager_load_relations(): void
diff --git a/tests/Unit/Views/Traits/Configuration/ComponentColumnConfigurationTest.php b/tests/Unit/Views/Traits/Configuration/ComponentColumnConfigurationTest.php
index 7e52c5d20..a86e3ae98 100644
--- a/tests/Unit/Views/Traits/Configuration/ComponentColumnConfigurationTest.php
+++ b/tests/Unit/Views/Traits/Configuration/ComponentColumnConfigurationTest.php
@@ -3,9 +3,11 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Traits\Configuration;
use Closure;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\ComponentColumn;
+#[Group('Columns')]
final class ComponentColumnConfigurationTest extends TestCase
{
public function test_component_column_can_set_slot_callback(): void
diff --git a/tests/Unit/Views/Traits/Helpers/ColumnCollapseHelpersTest.php b/tests/Unit/Views/Traits/Helpers/ColumnCollapseHelpersTest.php
index 3bdfad549..84749a68f 100644
--- a/tests/Unit/Views/Traits/Helpers/ColumnCollapseHelpersTest.php
+++ b/tests/Unit/Views/Traits/Helpers/ColumnCollapseHelpersTest.php
@@ -4,9 +4,11 @@
use Closure;
use Illuminate\Database\Eloquent\Builder;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Column;
+#[Group('Columns')]
final class ColumnCollapseHelpersTest extends TestCase
{
public function test_can_check_if_column_should_collapse_on_mobile(): void
diff --git a/tests/Unit/Views/Traits/Helpers/ColumnHelpersTest.php b/tests/Unit/Views/Traits/Helpers/ColumnHelpersTest.php
index 6a8e3f09f..60f733d18 100644
--- a/tests/Unit/Views/Traits/Helpers/ColumnHelpersTest.php
+++ b/tests/Unit/Views/Traits/Helpers/ColumnHelpersTest.php
@@ -4,9 +4,11 @@
use Closure;
use Illuminate\Database\Eloquent\Builder;
+use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Column;
+#[Group('Columns')]
final class ColumnHelpersTest extends TestCase
{
public function test_can_get_column_from(): void
diff --git a/tests/views/components/test-component.blade.php b/tests/views/components/test-component.blade.php
new file mode 100644
index 000000000..b84c60634
--- /dev/null
+++ b/tests/views/components/test-component.blade.php
@@ -0,0 +1,4 @@
+
+ Test
+
+
\ No newline at end of file
| | | | | |