| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace app\model\api;
- use think\facade\Db;
- use think\model;
- class CourseModel
- {
- protected $table = 'table_education_course';
- /**
- * 添加课程
- * @param $data
- * @return mixed
- */
- public function addCourse($data)
- {
- $result = Db::table($this->table)->insert($data);
- return $result;
- }
- /**
- * 获取所有课程
- *
- * @param string $keyword 模糊查询关键字
- * @return mixed
- */
- public function getCourse($keyword = '')
- {
- $query = Db::table($this->table)
- ->order('course_create_time', 'desc')
- ->field('course_id, course_topic, course_speaker, course_speaker_intro, course_price, course_play_count, course_create_time, course_audit, course_cover');
- if (!empty($keyword)) {
- $query->where('course_topic', 'like', "%{$keyword}%");
- }
- $courseList = $query->select();
- return $courseList;
- }
- /**
- * 删除课程
- * @param $course_id
- * @return mixed
- */
- public function deleteCourse($course_id)
- {
- $result = Db::table($this->table)->where('course_id', $course_id)->delete();
- return $result;
- }
- /**
- * 查找课程
- * @param $keyword
- * @return mixed
- */
- public function searchCourse($keyword)
- {
- $result = Db::table($this->table)->where('title', 'like', '%' . $keyword . '%')->select();
- return $result;
- }
- /**
- * 修改课程状态
- * @param $course_id
- * @param $course_status
- * @return mixed
- */
- public function updateCourseStatus($course_id, $course_status)
- {
- $result = Db::table($this->table)->where('course_id', $course_id)->update(['status' => $course_status]);
- return $result;
- }
- /**
- * 修改课程信息
- * @param $course_id
- * @param $data
- * @return mixed
- */
- public function updateCourseInfo($course_id, $data)
- {
- $result = Db::table($this->table)->where('course_id', $course_id)->update($data);
- return $result;
- }
- }
|