Skip to content

Commit

Permalink
Merge pull request #1 from CihanSenturk/add-morphOne-relation
Browse files Browse the repository at this point in the history
Add morph one relation
  • Loading branch information
cuneytsenturk authored Jul 12, 2024
2 parents f0ac8c5 + ddbbcff commit 5d852b3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Traits/Sortable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Schema;
Expand Down Expand Up @@ -135,7 +136,7 @@ private function queryJoinBuilder(Builder $query, $relation): Builder
$relation->getParent()->setTable($parentTable);
}

if ($relation instanceof HasOne) {
if ($relation instanceof HasOne || $relation instanceof MorphOne) {
$relatedPrimaryKey = $relation->getQualifiedForeignKeyName();
$parentPrimaryKey = $relation->getQualifiedParentKeyName();
} elseif ($relation instanceof BelongsTo) {
Expand Down

0 comments on commit 5d852b3

Please sign in to comment.