Skip to content

Commit f266e8c

Browse files
authored
Refactor whereRaw to use whereColumn (#25)
Addresses the issue with json field relationship. E.g { "object_type": "comment", "object_id": "1" } $this->morphOne(Notification::class, 'data->object';)
1 parent aa4aae8 commit f266e8c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/Morph.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ protected function queryCleanOrphan(Model $parentModel, Relation $relation, bool
115115
) {
116116
$query->select(DB::raw(1))
117117
->from($parentModel->getTable())
118-
->whereRaw(
119-
$parentModel->getTable().'.'.$parentModel->getKeyName().' = '.$childTable.'.'.$childFieldId
120-
);
118+
->whereColumn($parentModel->getTable() . '.' . $parentModel->getKeyName(), '=', $childTable . '.' . $childFieldId);
121119
})->$method();
122120
}
123121

0 commit comments

Comments
 (0)