private static function formater($datas, $single = false)
 {
     $lessonRegisterRepository = new LessonRegisterRepository();
     if ($single) {
         $datas['peoples'] = $lessonRegisterRepository->countByProperty('lesson_id', $datas['id']);
     } else {
         foreach ($datas as $dk => $dv) {
             $datas[$dk]['peoples'] = $lessonRegisterRepository->countByProperty('lesson_id', $dv['id']);
         }
     }
     $datas = parent::format($datas);
     return $datas;
 }
 private static function formater($datas, $single = false)
 {
     $lessonRepository = new LessonRepository();
     $lessons = $lessonRepository->findAll();
     foreach ($datas as $dk => $dv) {
         foreach ($lessons as $lk => $lv) {
             if ($lv['id'] == $dv['lesson_id']) {
                 $datas[$dk]['lesson_name'] = $lv['name'];
                 $datas[$dk]['lesson'] = $lv;
             }
         }
     }
     $datas = parent::format($datas);
     return $datas;
 }
 public function page($key = null, $profileId = 0, $rows = 25, $page = 1, $order = 'add_time desc')
 {
     $conditions = array();
     if (is_numeric($profileId) && $profileId > 0) {
         $conditions['profile_id'] = array('eq', $profileId);
     }
     if (!empty($key)) {
         $conditions['_string'] = ' (name like "%' . $key . '%")  OR ( mobile like "%' . $key . '%") OR (tencent like "%' . $key . '%") ';
     }
     $startRow = $rows * ($page - 1);
     $count = $this->_repository->where($conditions)->count();
     $data = $this->_repository->where($conditions)->order($order)->limit($startRow, $rows)->select();
     if (empty($data)) {
         $data = array();
     }
     $data = parent::format($data);
     $result = array('total' => $count, 'rows' => $data);
     return $result;
 }