diff --git a/CHANGELOG.md b/CHANGELOG.md
index e45450eaf..4958d0393 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
All notable changes to `laravel-livewire-tables` will be documented in this file
+## [v3.4.15] - 2024-08-25
+### New Features
+- BooleanColumn - Toggleable Callback by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1892
+
+### Tweaks
+- Doc Type Fixes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1891
+
## [v3.4.14] - 2024-08-25
### New Features
- Set Action Position (Left/Center/Right) and Set Actions in Toolbar by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1889
diff --git a/docs/column-types/boolean_columns.md b/docs/column-types/boolean_columns.md
index 8732db839..1888fa659 100644
--- a/docs/column-types/boolean_columns.md
+++ b/docs/column-types/boolean_columns.md
@@ -80,6 +80,46 @@ BooleanColumn::make('Active')
->yesNo()
```
+### Toggleable
+
+You may call a defined public function, which should live within your Table Component, to allow "toggling" against your database:
+
+```php
+BooleanColumn::make('Active', 'status')
+ ->toggleable('changeStatus'),
+```
+
+Then your "changeStatus" method may look like
+```php
+ public function changeStatus(int $id)
+ {
+ $item = $this->model::find($id);
+ $item->status = !$item->status;
+ $item->save();
+ }
+```
+
+### Toggleable Confirmation Message
+
+You may define a confirmation message prior to executing your toggleable() method. The method will only be executed upon confirming.
+```php
+BooleanColumn::make('Active', 'status')
+ ->confirmMessage('Are you sure that you want to change the status?')
+ ->toggleable('changeStatus'),
+```
+
+Then your "changeStatus" method may look like
+```php
+ public function changeStatus(int $id)
+ {
+ $item = $this->model::find($id);
+ $item->status = !$item->status;
+ $item->save();
+ }
+```
+
+
+### Additional Methods
Please also see the following for other available methods:
diff --git a/resources/views/includes/columns/boolean.blade.php b/resources/views/includes/columns/boolean.blade.php
index 1fb338512..3c48f56dc 100644
--- a/resources/views/includes/columns/boolean.blade.php
+++ b/resources/views/includes/columns/boolean.blade.php
@@ -1,40 +1,27 @@
-@if ($isTailwind)
- @if ($status)
- @if ($type === 'icons')
- @if ($successValue === true)
-
- @else
-
- @endif
- @elseif ($type === 'yes-no')
- @if ($successValue === true)
- Yes
- @else
- No
- @endif
- @endif
- @else
- @if ($type === 'icons')
- @if ($successValue === false)
-
- @else
-
- @endif
- @elseif ($type === 'yes-no')
- @if ($successValue === false)
- Yes
- @else
- No
- @endif
- @endif
- @endif
-@elseif ($isBootstrap)
+@if($isToggleable && $toggleMethod != '')
+
@endif
diff --git a/src/Traits/Configuration/FooterConfiguration.php b/src/Traits/Configuration/FooterConfiguration.php
index a438724fc..b84193312 100644
--- a/src/Traits/Configuration/FooterConfiguration.php
+++ b/src/Traits/Configuration/FooterConfiguration.php
@@ -46,14 +46,14 @@ public function setUseHeaderAsFooterDisabled(): self
return $this;
}
- public function setFooterTrAttributes(callable $callback): self
+ public function setFooterTrAttributes(\Closure $callback): self
{
$this->footerTrAttributesCallback = $callback;
return $this;
}
- public function setFooterTdAttributes(callable $callback): self
+ public function setFooterTdAttributes(\Closure $callback): self
{
$this->footerTdAttributesCallback = $callback;
diff --git a/src/Traits/Configuration/SecondaryHeaderConfiguration.php b/src/Traits/Configuration/SecondaryHeaderConfiguration.php
index 6982c47db..62acb5992 100644
--- a/src/Traits/Configuration/SecondaryHeaderConfiguration.php
+++ b/src/Traits/Configuration/SecondaryHeaderConfiguration.php
@@ -25,14 +25,14 @@ public function setSecondaryHeaderDisabled(): self
return $this;
}
- public function setSecondaryHeaderTrAttributes(callable $callback): self
+ public function setSecondaryHeaderTrAttributes(\Closure $callback): self
{
$this->secondaryHeaderTrAttributesCallback = $callback;
return $this;
}
- public function setSecondaryHeaderTdAttributes(callable $callback): self
+ public function setSecondaryHeaderTdAttributes(\Closure $callback): self
{
$this->secondaryHeaderTdAttributesCallback = $callback;
diff --git a/src/Traits/Configuration/TableAttributeConfiguration.php b/src/Traits/Configuration/TableAttributeConfiguration.php
index 972fd8604..01cf7376d 100644
--- a/src/Traits/Configuration/TableAttributeConfiguration.php
+++ b/src/Traits/Configuration/TableAttributeConfiguration.php
@@ -68,7 +68,7 @@ public function setTbodyAttributes(array $attributes = []): self
/**
* Set a list of attributes to override on the th elements
*/
- public function setThAttributes(callable $callback): self
+ public function setThAttributes(\Closure $callback): self
{
$this->thAttributesCallback = $callback;
@@ -78,7 +78,7 @@ public function setThAttributes(callable $callback): self
/**
* Set a list of attributes to override on the th sort button elements
*/
- public function setThSortButtonAttributes(callable $callback): self
+ public function setThSortButtonAttributes(\Closure $callback): self
{
$this->thSortButtonAttributesCallback = $callback;
@@ -88,7 +88,7 @@ public function setThSortButtonAttributes(callable $callback): self
/**
* Set a list of attributes to override on the td elements
*/
- public function setTrAttributes(callable $callback): self
+ public function setTrAttributes(\Closure $callback): self
{
$this->trAttributesCallback = $callback;
@@ -98,21 +98,21 @@ public function setTrAttributes(callable $callback): self
/**
* Set a list of attributes to override on the td elements
*/
- public function setTdAttributes(callable $callback): self
+ public function setTdAttributes(\Closure $callback): self
{
$this->tdAttributesCallback = $callback;
return $this;
}
- public function setTableRowUrl(callable $callback): self
+ public function setTableRowUrl(\Closure $callback): self
{
$this->trUrlCallback = $callback;
return $this;
}
- public function setTableRowUrlTarget(callable $callback): self
+ public function setTableRowUrlTarget(\Closure $callback): self
{
$this->trUrlTargetCallback = $callback;
diff --git a/src/Traits/Helpers/ConfigurableAreasHelpers.php b/src/Traits/Helpers/ConfigurableAreasHelpers.php
index 440f95ef4..23f50be55 100644
--- a/src/Traits/Helpers/ConfigurableAreasHelpers.php
+++ b/src/Traits/Helpers/ConfigurableAreasHelpers.php
@@ -21,12 +21,9 @@ public function hasConfigurableAreaFor(string $area): bool
return isset($this->configurableAreas[$area]) && $this->getConfigurableAreaFor($area) !== null;
}
- /**
- * @param string|array $area
- */
- public function getConfigurableAreaFor($area): ?string
+ public function getConfigurableAreaFor(string $area): ?string
{
- $area = $this->configurableAreas[$area] ?? null;
+ $area = array_key_exists($area, $this->configurableAreas) ? $this->configurableAreas[$area] : null;
if (is_array($area)) {
return $area[0];
@@ -35,13 +32,9 @@ public function getConfigurableAreaFor($area): ?string
return $area;
}
- /**
- * @param string|array $area
- * @return array
- */
- public function getParametersForConfigurableArea($area): array
+ public function getParametersForConfigurableArea(string $area): array
{
- $area = $this->configurableAreas[$area] ?? null;
+ $area = array_key_exists($area, $this->configurableAreas) ? $this->configurableAreas[$area] : null;
if (is_array($area) && isset($area[1]) && is_array($area[1])) {
return $area[1];
diff --git a/src/Traits/Helpers/SearchHelpers.php b/src/Traits/Helpers/SearchHelpers.php
index 2647dede0..4cde87290 100644
--- a/src/Traits/Helpers/SearchHelpers.php
+++ b/src/Traits/Helpers/SearchHelpers.php
@@ -123,7 +123,11 @@ public function getSearchOptions(): string
public function getSearchPlaceholder(): string
{
- return $this->hasSearchPlaceholder() ? $this->searchPlaceholder : __('Search');
+ if ($this->hasSearchPlaceholder()) {
+ return $this->searchPlaceholder;
+ }
+
+ return __('Search');
}
public function hasSearchPlaceholder(): bool
diff --git a/src/Traits/WithFooter.php b/src/Traits/WithFooter.php
index b1035cf29..8412d10fe 100644
--- a/src/Traits/WithFooter.php
+++ b/src/Traits/WithFooter.php
@@ -16,9 +16,9 @@ trait WithFooter
protected bool $columnsWithFooter = false;
- protected ?object $footerTrAttributesCallback;
+ protected ?\Closure $footerTrAttributesCallback;
- protected ?object $footerTdAttributesCallback;
+ protected ?\Closure $footerTdAttributesCallback;
public function setupFooter(): void
{
diff --git a/src/Traits/WithSecondaryHeader.php b/src/Traits/WithSecondaryHeader.php
index 875d0ae03..30ab4a797 100644
--- a/src/Traits/WithSecondaryHeader.php
+++ b/src/Traits/WithSecondaryHeader.php
@@ -14,9 +14,9 @@ trait WithSecondaryHeader
protected bool $columnsWithSecondaryHeader = false;
- protected ?object $secondaryHeaderTrAttributesCallback;
+ protected ?\Closure $secondaryHeaderTrAttributesCallback;
- protected ?object $secondaryHeaderTdAttributesCallback;
+ protected ?\Closure $secondaryHeaderTdAttributesCallback;
public function bootedWithSecondaryHeader(): void
{
diff --git a/src/Traits/WithTableAttributes.php b/src/Traits/WithTableAttributes.php
index b58c6baf0..0ec1884c1 100644
--- a/src/Traits/WithTableAttributes.php
+++ b/src/Traits/WithTableAttributes.php
@@ -21,15 +21,15 @@ trait WithTableAttributes
protected array $tbodyAttributes = [];
- protected ?object $thAttributesCallback;
+ protected ?\Closure $thAttributesCallback;
- protected ?object $thSortButtonAttributesCallback;
+ protected ?\Closure $thSortButtonAttributesCallback;
- protected ?object $trAttributesCallback;
+ protected ?\Closure $trAttributesCallback;
- protected ?object $tdAttributesCallback;
+ protected ?\Closure $tdAttributesCallback;
- protected ?object $trUrlCallback;
+ protected ?\Closure $trUrlCallback;
- protected ?object $trUrlTargetCallback;
+ protected ?\Closure $trUrlTargetCallback;
}
diff --git a/src/Views/Columns/BooleanColumn.php b/src/Views/Columns/BooleanColumn.php
index 1177f6e37..38dcf7216 100644
--- a/src/Views/Columns/BooleanColumn.php
+++ b/src/Views/Columns/BooleanColumn.php
@@ -7,12 +7,14 @@
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;
class BooleanColumn extends Column
{
use BooleanColumnConfiguration,
BooleanColumnHelpers,
+ HasConfirmation,
HasCallback;
protected string $type = 'icons';
@@ -21,6 +23,10 @@ class BooleanColumn extends Column
protected string $view = 'livewire-tables::includes.columns.boolean';
+ protected bool $isToggleable = false;
+
+ protected ?string $toggleMethod;
+
public function getContents(Model $row): null|string|\Illuminate\Support\HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
{
if ($this->isLabel()) {
@@ -30,6 +36,11 @@ public function getContents(Model $row): null|string|\Illuminate\Support\HtmlStr
$value = $this->getValue($row);
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())
diff --git a/src/Views/Columns/ColorColumn.php b/src/Views/Columns/ColorColumn.php
index 4d078add8..3c46013b7 100644
--- a/src/Views/Columns/ColorColumn.php
+++ b/src/Views/Columns/ColorColumn.php
@@ -17,7 +17,7 @@ class ColorColumn extends Column
ColorColumnHelpers;
use HasDefaultStringValue;
- public ?object $colorCallback = null;
+ public ?\Closure $colorCallback;
protected string $view = 'livewire-tables::includes.columns.color';
diff --git a/src/Views/Filters/DateFilter.php b/src/Views/Filters/DateFilter.php
index a3747adff..66965547a 100644
--- a/src/Views/Filters/DateFilter.php
+++ b/src/Views/Filters/DateFilter.php
@@ -23,14 +23,20 @@ public function validate(string $value): string|bool
{
$this->setInputDateFormat('Y-m-d')->setOutputDateFormat($this->getConfig('pillFormat') ?? 'Y-m-d');
$carbonDate = $this->createCarbonDate($value);
+ if ($carbonDate instanceof \Carbon\Carbon) {
+ return $carbonDate->format('Y-m-d');
+ }
- return ($carbonDate === false) ? false : $carbonDate->format('Y-m-d');
+ return false;
}
- public function getFilterPillValue($value): array|string|bool|null
+ public function getFilterPillValue($value): ?string
{
if ($this->validate($value)) {
- return $this->outputTranslatedDate($this->createCarbonDate($value));
+ $carbonDate = $this->createCarbonDate($value);
+ if ($carbonDate instanceof \Carbon\Carbon) {
+ return $this->outputTranslatedDate($carbonDate);
+ }
}
return null;
diff --git a/src/Views/Filters/DateTimeFilter.php b/src/Views/Filters/DateTimeFilter.php
index b499f8d09..3df56e7be 100644
--- a/src/Views/Filters/DateTimeFilter.php
+++ b/src/Views/Filters/DateTimeFilter.php
@@ -24,14 +24,20 @@ public function validate(string $value): string|bool
$this->setInputDateFormat('Y-m-d\TH:i')->setOutputDateFormat($this->getConfig('pillFormat'));
$carbonDate = $this->createCarbonDate($value);
+ if ($carbonDate instanceof \Carbon\Carbon) {
+ return $carbonDate->format('Y-m-d\TH:i');
+ }
- return ($carbonDate === false) ? false : $carbonDate->format('Y-m-d\TH:i');
+ return false;
}
- public function getFilterPillValue($value): array|string|bool|null
+ public function getFilterPillValue($value): ?string
{
if ($this->validate($value)) {
- return $this->outputTranslatedDate($this->createCarbonDate($value));
+ $carbonDate = $this->createCarbonDate($value);
+ if ($carbonDate && $carbonDate instanceof \Carbon\Carbon) {
+ return $this->outputTranslatedDate($carbonDate);
+ }
}
return null;
diff --git a/src/Views/Filters/NumberFilter.php b/src/Views/Filters/NumberFilter.php
index 6af596822..d942396cc 100644
--- a/src/Views/Filters/NumberFilter.php
+++ b/src/Views/Filters/NumberFilter.php
@@ -15,8 +15,16 @@ class NumberFilter extends Filter
protected string $view = 'livewire-tables::components.tools.filters.number';
- public function validate(mixed $value): float|int|bool
+ public function validate(float|int|string|array $value): float|int|string|false
{
- return is_numeric($value) ? $value : false;
+ if (is_array($value)) {
+ return false;
+ } elseif (is_float($value)) {
+ return (float) $value;
+ } elseif (is_int($value)) {
+ return (int) $value;
+ }
+
+ return false;
}
}
diff --git a/src/Views/Traits/Configuration/BooleanColumnConfiguration.php b/src/Views/Traits/Configuration/BooleanColumnConfiguration.php
index 05f39c329..68e98880a 100644
--- a/src/Views/Traits/Configuration/BooleanColumnConfiguration.php
+++ b/src/Views/Traits/Configuration/BooleanColumnConfiguration.php
@@ -6,9 +6,6 @@
trait BooleanColumnConfiguration
{
- /**
- * @return $this
- */
public function setSuccessValue(bool $value): self
{
$this->successValue = $value;
@@ -16,9 +13,6 @@ public function setSuccessValue(bool $value): self
return $this;
}
- /**
- * @return $this
- */
public function setView(string $view): self
{
$this->view = $view;
@@ -26,9 +20,6 @@ public function setView(string $view): self
return $this;
}
- /**
- * @return $this
- */
public function icons(): self
{
$this->type = 'icons';
@@ -36,13 +27,18 @@ public function icons(): self
return $this;
}
- /**
- * @return $this
- */
- public function yesNo()
+ public function yesNo(): self
{
$this->type = 'yes-no';
return $this;
}
+
+ public function toggleable(string $toggleMethod): self
+ {
+ $this->isToggleable = true;
+ $this->toggleMethod = $toggleMethod;
+
+ return $this;
+ }
}
diff --git a/src/Views/Traits/Configuration/ColorColumnConfiguration.php b/src/Views/Traits/Configuration/ColorColumnConfiguration.php
index 014e2cb80..1e0671b6a 100644
--- a/src/Views/Traits/Configuration/ColorColumnConfiguration.php
+++ b/src/Views/Traits/Configuration/ColorColumnConfiguration.php
@@ -6,7 +6,7 @@
trait ColorColumnConfiguration
{
- public function color(callable $callback): self
+ public function color(\Closure $callback): self
{
$this->colorCallback = $callback;
diff --git a/src/Views/Traits/Core/HasFooter.php b/src/Views/Traits/Core/HasFooter.php
index 1b4e015ad..54078f188 100644
--- a/src/Views/Traits/Core/HasFooter.php
+++ b/src/Views/Traits/Core/HasFooter.php
@@ -63,7 +63,7 @@ public function footerCallbackIsFilter(): bool
return $callback instanceof Filter;
}
- public function getFooterContents(mixed $rows, array $filterGenericData): string|HtmlString
+ public function getFooterContents(mixed $rows, array $filterGenericData): \Illuminate\Contracts\Foundation\Application|\Illuminate\View\Factory|\Illuminate\View\View|string|HtmlString
{
$value = null;
$callback = $this->getFooterCallback();
diff --git a/src/Views/Traits/Core/HasSecondaryHeader.php b/src/Views/Traits/Core/HasSecondaryHeader.php
index 1626fed68..666a9d312 100644
--- a/src/Views/Traits/Core/HasSecondaryHeader.php
+++ b/src/Views/Traits/Core/HasSecondaryHeader.php
@@ -63,7 +63,7 @@ public function secondaryHeaderCallbackIsFilter(): bool
return $callback instanceof Filter;
}
- public function getSecondaryHeaderContents(mixed $rows, array $filterGenericData): string|HtmlString
+ public function getSecondaryHeaderContents(mixed $rows, array $filterGenericData): \Illuminate\Contracts\Foundation\Application|\Illuminate\View\Factory|\Illuminate\View\View|string|HtmlString
{
$value = null;
$callback = $this->getSecondaryHeaderCallback();
diff --git a/src/Views/Traits/Helpers/BooleanColumnHelpers.php b/src/Views/Traits/Helpers/BooleanColumnHelpers.php
index 537d1c9b4..ae8bd33fb 100644
--- a/src/Views/Traits/Helpers/BooleanColumnHelpers.php
+++ b/src/Views/Traits/Helpers/BooleanColumnHelpers.php
@@ -15,4 +15,14 @@ public function getType(): string
{
return $this->type;
}
+
+ public function getIsToggleable(): bool
+ {
+ return $this->isToggleable ?? false;
+ }
+
+ public function getToggleMethod(): ?string
+ {
+ return $this->toggleMethod ?? null;
+ }
}
diff --git a/src/Views/Traits/Helpers/ColorColumnHelpers.php b/src/Views/Traits/Helpers/ColorColumnHelpers.php
index d437243e7..3f46b9085 100644
--- a/src/Views/Traits/Helpers/ColorColumnHelpers.php
+++ b/src/Views/Traits/Helpers/ColorColumnHelpers.php
@@ -10,7 +10,7 @@ trait ColorColumnHelpers
// TODO: Test
public function getColor(Model|int $row): string
{
- return $this->hasColorCallback() ? app()->call($this->getColorCallback(), ['row' => $row]) : ($this->getValue($row));
+ return $this->hasColorCallback() ? app()->call($this->getColorCallback(), ['row' => $row, 'value' => $row->{$this->getFrom()} ?? '']) : ($this->getValue($row));
}
public function getColorCallback(): ?callable
diff --git a/tests/Traits/Configuration/ColumnSelectConfigurationTest.php b/tests/Traits/Configuration/ColumnSelectConfigurationTest.php
index 98ef5dde5..2daf1e25a 100644
--- a/tests/Traits/Configuration/ColumnSelectConfigurationTest.php
+++ b/tests/Traits/Configuration/ColumnSelectConfigurationTest.php
@@ -99,7 +99,7 @@ public function test_can_check_all_columns_get_selected(): void
}
- public function test_check_get_selected_columns()
+ public function test_check_get_selected_columns(): void
{
$this->basicTable->deselectAllColumns();
@@ -116,6 +116,8 @@ public function test_can_check_all_columns_get_selected_and_extra_methods_work()
{
$this->assertTrue($this->basicTable->allSelectedColumnsAreVisibleByDefault());
+ $this->assertSame(8, count($this->basicTable->getDefaultVisibleColumns()));
+
$this->assertTrue($this->basicTable->allVisibleColumnsAreSelected());
$this->basicTable->deselectAllColumns();
diff --git a/tests/Views/Columns/BooleanColumnTest.php b/tests/Views/Columns/BooleanColumnTest.php
index 24b2663a8..6280af52c 100644
--- a/tests/Views/Columns/BooleanColumnTest.php
+++ b/tests/Views/Columns/BooleanColumnTest.php
@@ -77,4 +77,33 @@ public function test_can_return_status_false(): void
$curVal = $column->hasCallback() ? call_user_func($column->getCallback(), $value, $row) : (bool) $value === true;
$this->assertSame($curVal, false);
}
+
+ 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());
+ }
+
+ public function test_can_set_toggleable_with_confirm_message(): void
+ {
+ $column = BooleanColumn::make('Name', 'name')
+ ->toggleable('changeStatus');
+
+ $this->assertTrue($column->getIsToggleable());
+ $this->assertSame('changeStatus', $column->getToggleMethod());
+
+ $this->assertFalse($column->hasConfirmMessage());
+
+ $column->confirmMessage('Are you sure?');
+
+ $this->assertTrue($column->hasConfirmMessage());
+
+ $this->assertSame('Are you sure?', $column->getConfirmMessage());
+
+ }
}
diff --git a/tests/Views/Columns/ColorColumnTest.php b/tests/Views/Columns/ColorColumnTest.php
index 5288dbee7..62708c259 100644
--- a/tests/Views/Columns/ColorColumnTest.php
+++ b/tests/Views/Columns/ColorColumnTest.php
@@ -19,6 +19,9 @@ 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());
+
}
public function test_can_infer_field_name_from_title_if_no_from(): void
@@ -35,6 +38,13 @@ public function test_can_set_base_field_from_from(): void
$this->assertSame('favorite_color', $column->getField());
}
+ public function test_can_set_view(): void
+ {
+ $column = ColorColumn::make('Favorite Color', 'favorite_color');
+
+ $this->assertSame('livewire-tables::includes.columns.color', $column->getView());
+ }
+
public function test_can_set_default_value(): void
{
$column = ColorColumn::make('Favorite Color', 'favorite_color')->defaultValue('#FEFEFE');
diff --git a/tests/Views/Filters/NumberFilterTest.php b/tests/Views/Filters/NumberFilterTest.php
index 8c0f9bf54..17c2dc066 100644
--- a/tests/Views/Filters/NumberFilterTest.php
+++ b/tests/Views/Filters/NumberFilterTest.php
@@ -157,7 +157,8 @@ public function test_can_set_number_filter_to_number(): void
{
$filter = NumberFilter::make('BreedID');
$this->assertSame(123, $filter->validate(123));
- $this->assertSame(123, $filter->validate('123'));
+ $this->assertSame(123.51, $filter->validate(123.51));
+ $this->assertFalse($filter->validate('123'));
}
public function test_can_get_if_number_filter_empty(): void