zhangchangchun 5 lat temu
rodzic
commit
912802cf14

+ 0 - 1
app/Http/Controllers/V2/VideoGroupController.php

@@ -96,7 +96,6 @@ class VideoGroupController extends Controller {
             'name' => 'required|string|max:12',
             'name' => 'required|string|max:12',
             'video_info' => 'string'
             'video_info' => 'string'
         ]);
         ]);
-
         if ($validator->fails()) {
         if ($validator->fails()) {
             return $this->response->error($validator->errors()->first(), 500);
             return $this->response->error($validator->errors()->first(), 500);
         }
         }

+ 15 - 5
app/Repositories/V2/VideoGroupRepository.php

@@ -75,12 +75,22 @@ class VideoGroupRepository {
         DB::beginTransaction();
         DB::beginTransaction();
         try{
         try{
             $group = $videoGroup->save();
             $group = $videoGroup->save();
-            if(!empty($request['video_info'])){
-              $videoGroupInfo = json_decode($request['video_info']);
-              foreach ($videoGroupInfo as $key=>$value){
-                  $this->videoGroupInfo->where('id',$value->id)->update(['sort'=>$value->sort]);
-              }
+            if(is_array($request['video_info'])){
+                foreach ($request['video_info'] as $key=>$value){
+                    $this->videoGroupInfo->where('id',$value->id)->update(['sort'=>$value->sort]);
+                }
+            }else{
+                return Response::create([
+                    'message'  => '不是数组',
+                    'status_code'   => 500
+                ]);
             }
             }
+//            if(!empty($request['video_info'])){
+//              $videoGroupInfo = json_decode($request['video_info']);
+//              foreach ($videoGroupInfo as $key=>$value){
+//                  $this->videoGroupInfo->where('id',$value->id)->update(['sort'=>$value->sort]);
+//              }
+//            }
             DB::commit();
             DB::commit();
             return Response::create();
             return Response::create();
         }catch (QueryException $exception){
         }catch (QueryException $exception){