From 94a10811bfb86408b80e5edc37e4839410e31ebb Mon Sep 17 00:00:00 2001 From: Mh-Asmi Date: Fri, 17 May 2024 19:08:37 +0400 Subject: [PATCH] fix condition of source filter --- .../Modules/V5/Repository/Post/EloquentPostRepository.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Ushahidi/Modules/V5/Repository/Post/EloquentPostRepository.php b/src/Ushahidi/Modules/V5/Repository/Post/EloquentPostRepository.php index ba7afb6c1..cc47e0573 100644 --- a/src/Ushahidi/Modules/V5/Repository/Post/EloquentPostRepository.php +++ b/src/Ushahidi/Modules/V5/Repository/Post/EloquentPostRepository.php @@ -205,7 +205,10 @@ private function setSearchCondition(PostSearchFields $search_fields, $query, boo if (count($search_fields->source())) { $this->filter_joined_tables[] = 'messages'; - $query->leftJoin("messages", 'posts.id', '=', 'messages.post_id'); + $query->leftJoin('messages', function ($join) { + $join->on('posts.id', '=', 'messages.post_id'); + $join->where('messages.direction', '=', "incoming"); + }); if ($search_fields->webSource()) { $query->where(function ($builder) use ($search_fields) { $builder->whereNull('messages.type') @@ -222,7 +225,6 @@ private function setSearchCondition(PostSearchFields $search_fields, $query, boo } }); } - $query->where("messages.direction", "incoming"); } if ($search_fields->hasLocation() === 'mapped') {