Pārlūkot izejas kodu

将server_info get功能迁移到classify里面,修复混淆问题

chenxiqiang 6 gadus atpakaļ
vecāks
revīzija
99d0dc3a58

+ 34
- 1
manage-server/app/Http/Controllers/ClassifyController.php Parādīt failu

@@ -13,6 +13,39 @@ class ClassifyController extends Controller
13 13
         return Classify::paginate(100);
14 14
     }
15 15
 
16
+    /**
17
+     * 每页20进行分页
18
+     * @param Request $request
19
+     * @return mixed
20
+     */
21
+    public function home(Request $request)
22
+    {
23
+        $top = Classify::where("location", "top")->limit(3)->toArray();
24
+        $bottom = Classify::where("location", "bottom")->first();
25
+
26
+        $tops = array_map(function ($t) {
27
+            return [
28
+                "id" => $t["id"],
29
+                "server" => $t["server"],
30
+                "content" => $t["content"],
31
+                "photo" => $t["photo"],
32
+                "location" => $t["location"]
33
+            ];
34
+        }, $top);
35
+
36
+        return Response()->json([
37
+            "top" => $tops,
38
+            "introduce" => "服务介绍",
39
+            "bottom" => [
40
+                "id" => $bottom["id"],
41
+                "server" => $bottom["server"],
42
+                "content" => $bottom["content"],
43
+                "photo" => $bottom["photo"],
44
+                "location" => $bottom["location"]
45
+            ]
46
+        ]);
47
+    }
48
+
16 49
 
17 50
     /**
18 51
      * 获取某个记录
@@ -205,7 +238,7 @@ class ClassifyController extends Controller
205 238
                         "pid" => $record->pid,
206 239
                         "name" => $record->name,
207 240
                         "info" => $record->info,
208
-                        "content" => $record->content,
241
+                        "summary" => $record->summary,
209 242
                         "api" => $data["api"],
210 243
                         "fields" => $data["fields"]
211 244
                     ]

+ 5
- 1
manage-server/app/Models/Classify.php Parādīt failu

@@ -10,7 +10,11 @@ class Classify extends Model
10 10
         'pid', // 父id
11 11
         'name', // 名称
12 12
         'info', // 描述信息
13
-        'content', // 富文本介绍
13
+        'summary', // 富文本简介
14
+        'server', // 服务标题
15
+        'content', // 服务详情
16
+        'photo', // 首页显示的
17
+        'location', // 显示位置
14 18
     ];
15 19
 
16 20
     protected $children = [];

+ 4
- 0
manage-server/database/migrations/2018_08_20_075456_create_classifies_table.php Parādīt failu

@@ -19,7 +19,11 @@ class CreateClassifiesTable extends Migration
19 19
             $table->unsignedInteger('pid');
20 20
             $table->string('name');
21 21
             $table->string('info');
22
+            $table->text('summary');
22 23
             $table->text('content');
24
+            $table->string('server');
25
+            $table->string('photo');
26
+            $table->string('location');
23 27
         });
24 28
     }
25 29
 

Loading…
Atcelt
Saglabāt