ZxcZxc123 1 rok temu
rodzic
commit
ece2e37a34
1 zmienionych plików z 11 dodań i 4 usunięć
  1. 11 4
      app/system/controller/CourseController.php

+ 11 - 4
app/system/controller/CourseController.php

@@ -180,6 +180,10 @@ class CourseController
 
 
 
+    /**
+     * 修改审核状态
+     * @return mixed
+     */
     /**
      * 修改审核状态
      * @return mixed
@@ -187,12 +191,15 @@ class CourseController
     public function updateCourseAudit()
     {
         $course_id = Request::param('course_id');
-        $course_audit = Request::param('course_audit');
+        $course = CourseModel::find($course_id);
 
-        $courseModel = new CourseModel();
-        $result = $courseModel->updateAuditStatus($course_id, ['course_audit' => $course_audit]);
+        if (!$course) {
+            return app('json')->fail('课程不存在');
+        }
 
-        if ($result !== false) {
+        $course->course_audit = !$course->course_audit;
+
+        if ($course->save()) {
             return app('json')->success();
         } else {
             return app('json')->fail();