소스 검색

将首页和产品首页修改单独抽出来

chenxiqiang 6 년 전
부모
커밋
d7c8ae2b0c
2개의 변경된 파일48개의 추가작업 그리고 27개의 파일을 삭제
  1. 27
    16
      manage-server/app/Http/Controllers/ClassifyController.php
  2. 21
    11
      manage-server/app/Http/Controllers/ProductController.php

+ 27
- 16
manage-server/app/Http/Controllers/ClassifyController.php 파일 보기

@@ -49,28 +49,39 @@ class ClassifyController extends Controller
49 49
      */
50 50
     public function home(Request $request)
51 51
     {
52
-        $top = Classify::where("location", "top")->limit(3)->get()->toArray();
53
-        $bottom = Classify::where("location", "bottom")->first();
54
-
55
-        $tops = array_map(function ($t) {
56
-            return [
57
-                "id" => $t["id"],
58
-                "server" => $t["server"],
59
-                "content" => $t["content"],
60
-                "photo" => $t["photo"],
61
-                "location" => $t["location"]
62
-            ];
63
-        }, $top);
64
-
52
+        $homePage = HomePage::find(1);
53
+        $top1 = HomePage::find($homePage->top1);
54
+        $top2 = HomePage::find($homePage->top2);
55
+        $top3 = HomePage::find($homePage->top3);
56
+        $bottom = HomePage::find($homePage->bottom);
57
+        $introduce = HomePage::find($homePage->introduce);
65 58
         return Response()->json([
66
-            "top" => $tops,
67
-            "introduce" => "服务介绍",
59
+            "top" => [
60
+                [
61
+                    "id" => $top1["id"],
62
+                    "server" => $top1["server"],
63
+                    "content" => $top1["content"],
64
+                    "photo" => $top1["photo"],
65
+                ],
66
+                [
67
+                    "id" => $top2["id"],
68
+                    "server" => $top2["server"],
69
+                    "content" => $top2["content"],
70
+                    "photo" => $top2["photo"],
71
+                ],
72
+                [
73
+                    "id" => $top3["id"],
74
+                    "server" => $top3["server"],
75
+                    "content" => $top3["content"],
76
+                    "photo" => $top3["photo"],
77
+                ]
78
+            ],
79
+            "introduce" => $introduce,
68 80
             "bottom" => [
69 81
                 "id" => $bottom["id"],
70 82
                 "server" => $bottom["server"],
71 83
                 "content" => $bottom["content"],
72 84
                 "photo" => $bottom["photo"],
73
-                "location" => $bottom["location"]
74 85
             ]
75 86
         ]);
76 87
     }

+ 21
- 11
manage-server/app/Http/Controllers/ProductController.php 파일 보기

@@ -101,18 +101,28 @@ class ProductController extends Controller
101 101
      */
102 102
     public function home(Request $request)
103 103
     {
104
-        $top = Product::where("show", 1)->orderBy("updated_at", "desc")->limit(3)->get()->toArray();
105
-
106
-        $tops = array_map(function ($t) {
107
-            return [
108
-                "id" => $t["id"],
109
-                "name" => $t["name"],
110
-                "photo" => $t["photo"]
111
-            ];
112
-        }, $top);
113
-
104
+        $homePage = ProductPage::find(1);
105
+        $top1 = Product::find($homePage->top1);
106
+        $top2 = Product::find($homePage->top2);
107
+        $top3 = Product::find($homePage->top3);
114 108
         return Response()->json([
115
-            "data" => $tops,
109
+            "data" => [
110
+                [
111
+                    "id" => $top1["id"],
112
+                    "name" => $top1["name"],
113
+                    "photo" => $top1["photo"]
114
+                ],
115
+                [
116
+                    "id" => $top2["id"],
117
+                    "name" => $top2["name"],
118
+                    "photo" => $top2["photo"]
119
+                ],
120
+                [
121
+                    "id" => $top3["id"],
122
+                    "name" => $top3["name"],
123
+                    "photo" => $top3["photo"]
124
+                ],
125
+            ],
116 126
             "status" => 0,
117 127
         ]);
118 128
     }

Loading…
취소
저장