diff --git a/src/Scopes/ApprovalStateScope.php b/src/Scopes/ApprovalStateScope.php index 6b99c90..52d61f1 100644 --- a/src/Scopes/ApprovalStateScope.php +++ b/src/Scopes/ApprovalStateScope.php @@ -8,6 +8,7 @@ use Cjmellor\Approval\Events\ModelSetPending; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Database\Eloquent\Scope; use Illuminate\Support\Facades\Event; @@ -96,7 +97,8 @@ protected function addApprove(Builder $builder): void $modelId = $builder->getModel()->approvalable_id; - $model = new $modelClass(); + $morphedModel = Relation::getMorphedModel($modelClass) ?? $modelClass; + $model = new $morphedModel(); if ($modelId) { $model = $model->find($modelId);