Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,8 @@ protected function getCastType($key)
$convertedCastType = 'immutable_custom_datetime';
} elseif ($this->isDecimalCast($castType)) {
$convertedCastType = 'decimal';
} elseif (class_exists($castType)) {
$convertedCastType = $castType;
} else {
$convertedCastType = trim(strtolower($castType));
}
Expand Down
11 changes: 11 additions & 0 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,12 @@ public function testDirtyOnEnumArrayObject()
$this->assertTrue($model->isDirty('asEnumArrayObjectAttribute'));
}

public function testHasCastsOnEnumAttribute()
{
$model = new EloquentModelEnumCastingStub();
$this->assertTrue($model->hasCast('enumAttribute', StringStatus::class));
}

public function testCleanAttributes()
{
$model = new EloquentModelStub(['foo' => '1', 'bar' => 2, 'baz' => 3]);
Expand Down Expand Up @@ -3047,6 +3053,11 @@ protected function serializeDate(DateTimeInterface $date)
}
}

class EloquentModelEnumCastingStub extends Model
{
protected $casts = ['enumAttribute' => StringStatus::class];
}

class EloquentModelDynamicHiddenStub extends Model
{
protected $table = 'stub';
Expand Down