Skip to content

Commit 0e5edde

Browse files
committed
added custom_datetime as valid things to cast to date when writing to database
1 parent d381e2f commit 0e5edde

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"ext-json": "*"
3232
},
3333
"require-dev": {
34-
"orchestra/testbench": "^5.0 || ^6.0",
34+
"orchestra/testbench": "^5.0 || ^6.0 || ^7.0",
3535
"mockery/mockery": "^1.4"
3636
},
3737
"extra": {

src/Database/Eloquent/Concerns/FMHasAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait FMHasAttributes
1717
protected function isDateCastable($key)
1818
{
1919
// We need to also cast timestamps as
20-
return $this->hasCast($key, ['date', 'datetime', 'immutable_date', 'immutable_datetime', 'timestamp']);
20+
return $this->hasCast($key, ['date', 'datetime', 'immutable_date', 'immutable_datetime', 'timestamp', 'custom_datetime']);
2121
}
2222

2323
}

src/Database/Eloquent/FMModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public function setAttribute($key, $value)
486486
$value = $this->attributes[$key];
487487

488488
// When writing dates the regular datetime format won't work, so we have to get JUST the date value
489-
if ($this->isDateAttribute($key) && $this->hasCast($key, ['date'])) {
489+
if ($this->isDateAttribute($key)) {
490490
$value = Arr::first(explode(' ', $value));
491491
}
492492

0 commit comments

Comments
 (0)