Skip to content

Commit da2e6c8

Browse files
committed
Merging casts
1 parent a307fab commit da2e6c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/JoinsHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public static function ensureModelIsUniqueToQuery($query): void
9898

9999
// Ensure the model of the cloned query is unique to the query.
100100
$query->setModel($model = new $originalModel());
101+
$model->mergeCasts($originalModel->getCasts());
101102

102103
// Update any `beforeQueryCallbacks` to link to the new `$this` as Eloquent Query,
103104
// otherwise the reference to the current Eloquent query goes wrong. These query
@@ -175,8 +176,8 @@ public function getAliasName(bool $useAlias, Relation $relation, string $relatio
175176

176177
if (is_array($callback) && $relation instanceof HasOneOrManyThrough) {
177178
$alias = [null, null];
178-
179179
$throughParentTable = $relation->getThroughParent()->getTable();
180+
180181
if (isset($callback[$throughParentTable])) {
181182
$fakeJoinCallback = new FakeJoinCallback($relation->getBaseQuery(), 'inner', $throughParentTable);
182183
$callback[$throughParentTable]($fakeJoinCallback);

0 commit comments

Comments
 (0)