withGlobalScope('entity', new EntityScope()); } public function withoutGlobalScope($scope): static { // Prevent removal of the entity scope if ($scope === 'entity') { return $this; } return parent::withoutGlobalScope($scope); } /** * Override the default forceDelete method to add type filter onto the query * since it specifically ignores scopes by default. */ public function forceDelete() { return $this->query->where('type', '=', $this->model->getMorphClass())->delete(); } }