/** * دریافت تعداد کامنتهای زیر هر پست * @param int $n * @return Illuminate\Support\Collection */ public function listsWithcommentsCount($n) { $Res = $this->model->selectRaw('posts_tbl.pst_id, posts_tbl.title, posts_tbl.active, count(*) as aggregate')->join('comments_tbl', 'posts_tbl.pst_id', '=', 'comments_tbl.pst_id')->whereActive(true)->groupBy('posts_tbl.pst_id')->orderBy('aggregate', 'desc')->take($n)->get(); return $Res; }