Skip to content

Commit d9bd74c

Browse files
committed
add handling for json/array field direct updating
1 parent 8ca006c commit d9bd74c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Database/Eloquent/Concerns/FMHasAttributes.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public function setAttribute($key, $value)
1818
{
1919
parent::setAttribute($key, $value);
2020

21+
// don't deal with json casting, already done in the call above
22+
if (str_contains($key, '->')) {
23+
return;
24+
}
25+
2126
$value = $this->attributes[$key];
2227

2328
// Check if we still have a DateTime object due to custom formatting and convert it to a string to write to FM.
@@ -27,10 +32,10 @@ public function setAttribute($key, $value)
2732
// We could convert the DateTime to a string at the time when we're preparing the API call, but at that point
2833
// we won't be in the model and won't have access to the cast type to determine if we should strip out the
2934
// time data.
30-
3135
if ($value instanceof DateTime) {
3236
$value = $value->format($this->dateFormat);
3337
}
38+
3439
// When writing dates the regular datetime format won't work, so we have to get JUST the date value
3540
// check the key's cast to see if it is cast to a date or custom date:format
3641
$castType = $this->getCasts()[$key] ?? '';

0 commit comments

Comments
 (0)