Skip to content

Commit b10ec61

Browse files
committed
handle empty casted fields as null
1 parent 20be4ac commit b10ec61

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Database/Eloquent/Concerns/FMHasAttributes.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,15 @@ public function setAttribute($key, $value)
5353

5454
return $this;
5555
}
56+
57+
protected function castAttribute($key, $value)
58+
{
59+
// FileMaker doesn't have `null` as a value, but we should consider an empty string as null for casting purposes
60+
// since any of the cast types wouldn't normally handle an empty string as a valid value.
61+
if ($value === '') {
62+
$value = null;
63+
}
64+
65+
return parent::castAttribute($key, $value);
66+
}
5667
}

0 commit comments

Comments
 (0)