Skip to content

Commit

Permalink
Refactor whereRaw to use whereColumn (#25)
Browse files Browse the repository at this point in the history
Addresses the issue with json field relationship. E.g
{
"object_type": "comment",
"object_id": "1"
} 

$this->morphOne(Notification::class, 'data->object';)
  • Loading branch information
sadiqsalau authored Nov 27, 2023
1 parent aa4aae8 commit f266e8c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Morph.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ protected function queryCleanOrphan(Model $parentModel, Relation $relation, bool
) {
$query->select(DB::raw(1))
->from($parentModel->getTable())
->whereRaw(
$parentModel->getTable().'.'.$parentModel->getKeyName().' = '.$childTable.'.'.$childFieldId
);
->whereColumn($parentModel->getTable() . '.' . $parentModel->getKeyName(), '=', $childTable . '.' . $childFieldId);
})->$method();
}

Expand Down

0 comments on commit f266e8c

Please sign in to comment.