duqinya лет назад: 5
Родитель
Сommit
664ba394c1

+ 0 - 6
app/Http/Controllers/V2/PlatformContentController.php

@@ -22,12 +22,6 @@ class PlatformContentController extends BaseController
     //平台内容列表
     public function index(Request $request)
     {
-        $validator = Validator::make($request->all(), [
-            'id' => 'required|integer',
-        ]);
-        if ($validator->fails()) {
-            return $this->jsonError($validator->errors()->first());
-        }
         $platformContent = $this->platformContentRepository->index($request->all());
         return $this->jsonSuccess($platformContent);
 

+ 8 - 3
app/Repositories/PlatformContentRepository.php

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

+ 4 - 0
app/Repositories/StarNewsRepository.php

@@ -19,6 +19,10 @@ class StarNewsRepository
 
     public function index($request)
     {
+        if (isset($request['id'])){
+            return $this->starNews
+                ->where('id',$request['id'])->orderBy('id', 'desc')->first();
+        }
         $this->starNews = $this->starNews
             ->orderBy('id', 'desc')->get();