瀏覽代碼

修改返回

duqinya 5 年之前
父節點
當前提交
9a104c4c9d

+ 2 - 5
app/Http/Controllers/V2/PlatformContentController.php

@@ -29,10 +29,7 @@ class PlatformContentController extends BaseController
             return $this->jsonError($validator->errors()->first());
         }
         $platformContent = $this->platformContentRepository->index($request->all());
-        if ($platformContent){
-            return $this->jsonSuccess($platformContent);
-        }else {
-            return $this->jsonError('没有找到相关平台内容');
-        }
+        return $this->jsonSuccess($platformContent);
+
     }
 }

+ 1 - 5
app/Http/Controllers/V2/StarNewsController.php

@@ -27,10 +27,6 @@ class StarNewsController extends BaseController
     public function index(Request $request)
     {
         $starNews = $this->starNewsRepository->index($request->all());
-        if ($starNews){
-            return $this->jsonSuccess($starNews);
-        }else {
-            return $this->jsonError('没有找到相关新闻');
-        }
+        return $this->jsonSuccess($starNews);
     }
 }

+ 1 - 5
app/Repositories/PlatformContentRepository.php

@@ -19,12 +19,8 @@ class PlatformContentRepository
 
     public function index($request)
     {
-        $where = [];
-        if(isset($request['id'])){
-            $where[] = ['id',$request['id']];
-        }
         $this->platformContent = $this->platformContent
-            ->where($where)->orderBy('id', 'desc')->get();
+            ->where('id',$request['id'])->orderBy('id', 'desc')->first();
 
         return $this->platformContent;
     }