On domain list, also include echoareas without messages.

This commit is contained in:
Deon George 2023-08-04 09:53:40 +10:00
parent c59f8ee0ed
commit df541984ab
1 changed files with 3 additions and 2 deletions

View File

@ -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();
}