public function searchPovod($params) { $query = new Query(); $query->Select("p.*,\n u.name username,\n i.image as image,\n i.autor as autor_image,\n t.autor as autor_text,\n t.text text,\n a.happyday isp,\n f.email,\n f.nati,\n f.prefics,\n i.id image_id,\n t.id text_id,\n u.public_email")->from('povod p')->leftjoin('otk_image i', 'i.povod_id = p.povod_id')->leftjoin('otk_text t', 't.povod_id = p.povod_id')->leftjoin('arhiv a', 'p.povod_id=a.povod_id and a.frend_id = p.frend_id and a.happyday=p.happyday')->leftJoin('frends f', 'f.id = p.frend_id')->leftJoin('profile u', 'u.user_id = p.user_id')->where($params)->groupBy(['p.frend_id', 'p.povod_id'])->orderBy(['p.happyday' => 'asc', 'p.povodname' => 'asc', 'p.frendname' => 'asc']); $dataProvider = new ActiveDataProvider(['query' => $query]); return $dataProvider; }