Skip to content

Commit

Permalink
fixed HasOneThrough relationship on laravel-11's change.
Browse files Browse the repository at this point in the history
  • Loading branch information
陆云峰 committed Oct 17, 2024
1 parent 8a09410 commit e73a0c9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Database/Eloquent/RelationMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
use Illuminate\Database\Eloquent\Relations\HasOneOrManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Database\Eloquent\Relations\MorphOneOrMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
Expand Down Expand Up @@ -132,7 +133,7 @@ public function getRelationExistenceInQuery(): Closure
$this instanceof BelongsTo => $belongsTo($query, $parentQuery),
$this instanceof BelongsToMany => $belongsToMany($query, $parentQuery),
$this instanceof HasOneOrMany => $hasOneOrMany($query, $parentQuery),
$this instanceof HasOneOrManyThrough => $hasOneOrManyThrough($query, $parentQuery),
$this instanceof HasOneThrough, $this instanceof HasManyThrough => $hasOneOrManyThrough($query, $parentQuery),
default => throw new LogicException(
sprintf('%s must be a relationship instance.', $this::class)
)
Expand All @@ -145,7 +146,7 @@ public function getRelationWhereInKey(): Closure
return fn (): string => match (true) {
$this instanceof BelongsTo => $this->getQualifiedForeignKeyName(),
$this instanceof HasOneOrMany, $this instanceof BelongsToMany => $this->getQualifiedParentKeyName(),
$this instanceof HasOneOrManyThrough => $this->getQualifiedLocalKeyName(),
$this instanceof HasOneThrough, $this instanceof HasManyThrough => $this->getQualifiedLocalKeyName(),
default => throw new LogicException(
sprintf('%s must be a relationship instance.', $this::class)
)
Expand Down

0 comments on commit e73a0c9

Please sign in to comment.