|
@@ -44,6 +44,46 @@ class Education
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取课程详情
|
|
|
|
|
+ * @param $gr_id
|
|
|
|
|
+ * @return mixed
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getCourseDetail($gr_id)
|
|
|
|
|
+ {
|
|
|
|
|
+ $course = EducationCourse::where('gr_id', $gr_id)
|
|
|
|
|
+ ->where('course_status', 1)
|
|
|
|
|
+ ->where('course_audit', 1)
|
|
|
|
|
+ ->find();
|
|
|
|
|
+
|
|
|
|
|
+ if (!$course) {
|
|
|
|
|
+ return app('json')->fail('课程不存在');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $course = $course->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $education = \app\model\api\Education::where('gr_id', $course['gr_id'])
|
|
|
|
|
+ ->where('audit', 1)
|
|
|
|
|
+ ->find();
|
|
|
|
|
+
|
|
|
|
|
+ if (!$education) {
|
|
|
|
|
+ return app('json')->fail('课程不存在或未通过审核');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $education = $education->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $course['edu_name'] = $education['name'];
|
|
|
|
|
+ $course['edu_logo'] = $education['logo'];
|
|
|
|
|
+ $course['edu_type1'] = $education['type1'];
|
|
|
|
|
+ $course['edu_type2'] = $education['type2'];
|
|
|
|
|
+
|
|
|
|
|
+ return app('json')->success($course);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取轮播列表
|
|
* 获取轮播列表
|
|
|
* @return mixed
|
|
* @return mixed
|
|
@@ -66,30 +106,6 @@ class Education
|
|
|
* 获取课程组列表
|
|
* 获取课程组列表
|
|
|
* @return mixed
|
|
* @return mixed
|
|
|
*/
|
|
*/
|
|
|
-// public function getCourseList()
|
|
|
|
|
-// {
|
|
|
|
|
-// $where['audit'] = 1;
|
|
|
|
|
-// $type1 = input('type', '');
|
|
|
|
|
-// if ($type1 !== '') {
|
|
|
|
|
-// $where['type1'] = $type1;
|
|
|
|
|
-// }
|
|
|
|
|
-// $grlist = \app\model\api\Education::where($where)
|
|
|
|
|
-// ->limit(20)
|
|
|
|
|
-// ->order('od asc,recommend desc,gr_id desc')
|
|
|
|
|
-// ->select()
|
|
|
|
|
-// ->toArray();
|
|
|
|
|
-// foreach ($grlist as &$v) {
|
|
|
|
|
-// $count = EducationCourse::where('course_status', 1)
|
|
|
|
|
-// ->where('gr_id', $v['gr_id'])
|
|
|
|
|
-// ->where('course_audit', 1)
|
|
|
|
|
-// ->field('count(*) as count,sum(course_play_count) as alll')
|
|
|
|
|
-// ->find();
|
|
|
|
|
-// $v['count'] = $count['count'];
|
|
|
|
|
-// $count['alll'] += $v['times'];
|
|
|
|
|
-// $v['alll'] = $count['alll'] ? $count['alll'] : 0;
|
|
|
|
|
-// }
|
|
|
|
|
-// return app('json')->success(['data' => $grlist]);
|
|
|
|
|
-// }
|
|
|
|
|
private function getCountAndAlll($grlist)
|
|
private function getCountAndAlll($grlist)
|
|
|
{
|
|
{
|
|
|
foreach ($grlist as &$v) {
|
|
foreach ($grlist as &$v) {
|