From 4b948b1682ef565aa367e3a651ae69fe37b0f400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Dalmolin?= Date: Tue, 26 Mar 2024 07:38:51 -0300 Subject: [PATCH] Replacing dots in table definition alias to avoid issues with postgres --- src/Mixins/RelationshipsExtraMethods.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mixins/RelationshipsExtraMethods.php b/src/Mixins/RelationshipsExtraMethods.php index b838c66..02ebd6c 100644 --- a/src/Mixins/RelationshipsExtraMethods.php +++ b/src/Mixins/RelationshipsExtraMethods.php @@ -393,11 +393,11 @@ public function performHavingForEloquentPowerJoins() $modelInstance = new $morphable; $builder - ->selectRaw(sprintf('count(%s) as %s_count', $modelInstance->getQualifiedKeyName(), $modelInstance->getTable())) + ->selectRaw(sprintf('count(%s) as %s_count', $modelInstance->getQualifiedKeyName(), Str::replace('.', '_', $modelInstance->getTable()))) ->havingRaw(sprintf('count(%s) %s %d', $modelInstance->getQualifiedKeyName(), $operator, $count)); } else { $builder - ->selectRaw(sprintf('count(%s) as %s_count', $this->query->getModel()->getQualifiedKeyName(), $this->query->getModel()->getTable())) + ->selectRaw(sprintf('count(%s) as %s_count', $this->query->getModel()->getQualifiedKeyName(), Str::replace('.', '_', $this->query->getModel()->getTable()))) ->havingRaw(sprintf('count(%s) %s %d', $this->query->getModel()->getQualifiedKeyName(), $operator, $count)); } };