Open
Description
✏️ Describe the bug
Cannot update data collections that are null by default.
↪️ To Reproduce
it('can update a model where the cast is initially null', function () {
$model = new DummyModelWithCasts();
$model->setRawAttributes(['data_collection' => null]);
$model->save();
assertDatabaseHas(DummyModelWithCasts::class, [
'data_collection' => null,
]);
$model->update([
'data_collection' => \Illuminate\Support\Collection::make([new SimpleData('Test')]),
]);
assertDatabaseHas(DummyModelWithCasts::class, [
'data_collection' => json_encode([['string' => 'Test']]),
]);
});
✅ Expected behavior
Should be able to update from null
🖥️ Versions
Laravel: 12.x
Laravel Data: 1.17.0
PHP: 8.3
Metadata
Metadata
Assignees
Labels
No labels