Skip to content

Commit

Permalink
Update BelongsToThrough.php
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMuller committed Sep 4, 2024
1 parent 9d2ef94 commit 753c633
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Relations/BelongsToThrough.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Expression;
use Illuminate\Support\Str;
use RuntimeException;

/**
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
Expand Down Expand Up @@ -341,7 +342,7 @@ public function getFirstForeignKeyName()
$firstThroughParent = end($this->throughParents);

if ($firstThroughParent === false) {
$firstThroughParent = $this->parent;
throw new RuntimeException('No "through" parent models were specified.');
}

return $this->prefix . $this->getForeignKeyName($firstThroughParent);
Expand All @@ -357,7 +358,7 @@ public function getQualifiedFirstLocalKeyName()
$lastThroughParent = end($this->throughParents);

if ($lastThroughParent === false) {
$lastThroughParent = $this->parent;
throw new RuntimeException('No "through" parent models were specified.');
}

return $lastThroughParent->qualifyColumn($this->getLocalKeyName($lastThroughParent));
Expand Down

0 comments on commit 753c633

Please sign in to comment.