Skip to content

Commit

Permalink
Return model when casting attribute (#45539)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Jan 6, 2023
1 parent 0159017 commit 8c9ae32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Expand Up @@ -1070,6 +1070,8 @@ protected function setAttributeMarkedMutatedAttributeValue($key, $value)
} else {
unset($this->attributeCastCache[$key]);
}

return $this;
}

/**
Expand Down
Expand Up @@ -47,6 +47,10 @@ public function testBasicCustomCasting()

$this->assertSame('DRIES', $model->uppercase);

$model = $model->setAttribute('uppercase', 'james');

$this->assertInstanceOf(TestEloquentModelWithAttributeCast::class, $model);

$model = new TestEloquentModelWithAttributeCast;

$model->address = $address = new AttributeCastAddress('110 Kingsbrook St.', 'My Childhood House');
Expand Down

0 comments on commit 8c9ae32

Please sign in to comment.