From df541984abc056e18913bbab9ad187ac92ced78b Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 4 Aug 2023 09:53:40 +1000 Subject: [PATCH] On domain list, also include echoareas without messages. --- app/Models/Domain.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Models/Domain.php b/app/Models/Domain.php index e2f572c..5bc2f1e 100644 --- a/app/Models/Domain.php +++ b/app/Models/Domain.php @@ -123,14 +123,15 @@ class Domain extends Model ->elseRaw("'all'"); return Echoarea::cacheFor(self::CACHE_TIME) - ->select(['echoareas.id','name','description','active',DB::raw('count(echoareas.id) AS count'),DB::raw('max(datetime) as last_message')]) + ->select(['echoareas.id','name','description','active',DB::raw('count(echomails.id) AS count'),DB::raw('max(datetime) as last_message')]) ->selectRaw($case->toRaw().' AS stats') - ->join('echomails',['echomails.echoarea_id'=>'echoareas.id']) + ->join('echomails',['echomails.echoarea_id'=>'echoareas.id'],NULL,NULL,'left outer') ->where('domain_id',$this->id) ->groupBy('echoareas.id') ->groupBy('echoareas.name') ->groupBy('stats') ->orderBy('echoareas.name') + ->orderBy('last_message','DESC') ->get(); }