Skip to content

Commit 5d852b3

Browse files
Merge pull request #1 from CihanSenturk/add-morphOne-relation
Add morph one relation
2 parents f0ac8c5 + ddbbcff commit 5d852b3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Traits/Sortable.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Database\Eloquent\Builder;
99
use Illuminate\Database\Eloquent\Relations\BelongsTo;
1010
use Illuminate\Database\Eloquent\Relations\HasOne;
11+
use Illuminate\Database\Eloquent\Relations\MorphOne;
1112
use Illuminate\Support\Arr;
1213
use Illuminate\Support\Str;
1314
use Illuminate\Support\Facades\Schema;
@@ -135,7 +136,7 @@ private function queryJoinBuilder(Builder $query, $relation): Builder
135136
$relation->getParent()->setTable($parentTable);
136137
}
137138

138-
if ($relation instanceof HasOne) {
139+
if ($relation instanceof HasOne || $relation instanceof MorphOne) {
139140
$relatedPrimaryKey = $relation->getQualifiedForeignKeyName();
140141
$parentPrimaryKey = $relation->getQualifiedParentKeyName();
141142
} elseif ($relation instanceof BelongsTo) {

0 commit comments

Comments
 (0)