diff --git a/lib/Models/Segment.php b/lib/Models/Segment.php index a7c5cb4e88..0fd1029716 100644 --- a/lib/Models/Segment.php +++ b/lib/Models/Segment.php @@ -268,6 +268,7 @@ class Segment extends Model { [MP_SUBSCRIBER_SEGMENT_TABLE . '.subscriber_id', '=', MP_SUBSCRIBERS_TABLE . '.id']) ->groupBy(self::$_table . '.id') ->groupBy(self::$_table . '.name') + ->groupBy(self::$_table . '.type') ->orderByAsc(self::$_table . '.name') ->whereNull(self::$_table . '.deleted_at'); diff --git a/lib/Newsletter/Listing/NewsletterListingRepository.php b/lib/Newsletter/Listing/NewsletterListingRepository.php index a109b164f7..797dd7c963 100644 --- a/lib/Newsletter/Listing/NewsletterListingRepository.php +++ b/lib/Newsletter/Listing/NewsletterListingRepository.php @@ -51,6 +51,7 @@ class NewsletterListingRepository extends ListingRepository { ->join('n.newsletterSegments', 'ns') ->join('ns.segment', 's') ->groupBy('s.id') + ->addGroupBy('s.name') ->orderBy('s.name') ->having('COUNT(n) > 0');