Skip to content

Commit 98af496

Browse files
Handle boolean date attribute not being set yet
1 parent 5a8132b commit 98af496

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/BooleanDateAttribute.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ class BooleanDateAttribute extends Attribute
1212
public static function for(string $column): static
1313
{
1414
return parent::make(
15-
get: static fn (?string $value, array $attributes): bool => $attributes[$column] !== null,
15+
get: static fn (?string $value, array $attributes): bool => static::getBooleanDate($value, $attributes, $column),
1616
set: static fn (mixed $value, array $attributes): array => static::setBooleanDate($value, $attributes, $column),
1717
);
1818
}
1919

20+
private static function getBooleanDate(mixed $value, array $attributes, string $column): bool
21+
{
22+
return array_key_exists($column, $attributes) && $attributes[$column] !== null;
23+
}
24+
2025
private static function setBooleanDate(mixed $value, array $attributes, string $column): array
2126
{
2227
// Only update the field if it's never been set before or when it's being "disabled"

0 commit comments

Comments
 (0)