Skip to content

Commit cdbbd85

Browse files
author
Cristian Llanos
committed
Treat Soft Deletes field as string
Due to some casting problems when converting null to a Carbon instance, we are going to treat Soft Deletes field as string in Eloquent models.
1 parent b5858bf commit cdbbd85

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Coders/Model/Model.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,14 @@ protected function parseColumn(Fluent $column)
235235
// TODO: Check type cast is OK
236236
$cast = $column->type;
237237

238+
// Due to some casting problems when converting null to Carbon
239+
// we are going to treat Soft Deletes field as string.
240+
if ($column->name == $this->getDeletedAtField()) {
241+
$cast = 'string';
242+
}
243+
238244
// Track dates
239-
if ($cast == 'date' && $column->name != $this->getDeletedAtField()) {
245+
if ($cast == 'date') {
240246
$this->dates[] = $column->name;
241247
}
242248
// Track attribute casts

0 commit comments

Comments
 (0)