Skip to content

Commit 439ddb7

Browse files
author
Michael Deck
committed
Add back missed null and boolean conversions
1 parent f6d7ae4 commit 439ddb7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Database/Eloquent/FMModel.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,21 @@ public function setAttribute($key, $value)
474474
{
475475
parent::setAttribute($key, $value);
476476

477+
$value = $this->attributes[$key];
478+
477479
// When writing dates the regular datetime format won't work, so we have to get JUST the date value
478480
if ($this->isDateAttribute($key) && $this->hasCast($key, ['date'])) {
479-
$value = Arr::first(explode(' ', $this->attributes[$key]));
481+
$value = Arr::first(explode(' ', $value));
482+
}
483+
484+
// FileMaker can't handle true and false, so we need to change to 1 and 0
485+
if (is_bool($value)) {
486+
$value = $value ? 1 : 0;
487+
}
488+
489+
// FileMaker can't handle null, so change it to ''
490+
if (is_null($value)) {
491+
$value = '';
480492
}
481493

482494
$this->attributes[$key] = $value;

0 commit comments

Comments
 (0)