Skip to content
Closed
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
3 changes: 2 additions & 1 deletion src/JoinsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static function ensureModelIsUniqueToQuery($query): void

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

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

if (is_array($callback) && $relation instanceof HasOneOrManyThrough) {
$alias = [null, null];

$throughParentTable = $relation->getThroughParent()->getTable();

if (isset($callback[$throughParentTable])) {
$fakeJoinCallback = new FakeJoinCallback($relation->getBaseQuery(), 'inner', $throughParentTable);
$callback[$throughParentTable]($fakeJoinCallback);
Expand Down
Loading