|
@@ -51,4 +51,40 @@ class Index extends Api
|
|
|
$this->success(1,$result);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ //搜索
|
|
|
+ public function search(){
|
|
|
+ $keyword = input('keyword','','trim');
|
|
|
+ if(empty($keyword)){
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+
|
|
|
+ //搜课时表
|
|
|
+ $where = [
|
|
|
+ 'lesson.name|lesson.name_en' => ['LIKE','%'.$keyword.'%'],
|
|
|
+ 'slot.starttime' => ['gt',time()],//未开始
|
|
|
+ 'slot.status' => 0,//报名中
|
|
|
+ ];
|
|
|
+
|
|
|
+ $list = Db::name('lesson_slot')->alias('slot')
|
|
|
+ ->field('slot.*,lesson.name,lesson.name_en,lesson.image,lesson.price')
|
|
|
+ ->join('lesson','slot.lesson_id = lesson.id','LEFT')
|
|
|
+ ->where($where)->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['image']);
|
|
|
+ $list = $this->list_lang($list,['name']);
|
|
|
+
|
|
|
+ //准备教练数据
|
|
|
+ $coach_list = Db::name('coach')->column('id,nickname');
|
|
|
+ foreach($list as $key => &$slot){
|
|
|
+ //放入教练
|
|
|
+ $coach_text = '';
|
|
|
+ $coach_ids = explode(',',$slot['coach_ids']);
|
|
|
+ foreach($coach_ids as $coach_id){
|
|
|
+ $coach_text .= $coach_list[$coach_id].',';
|
|
|
+ }
|
|
|
+ $slot['coach_text'] = substr($coach_text,0,-1);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
}
|