Просмотр исходного кода

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

chenxiqiang 6 лет назад
Родитель
Сommit
99d0dc3a58

+ 34
- 1
manage-server/app/Http/Controllers/ClassifyController.php Просмотреть файл

13
         return Classify::paginate(100);
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
                         "pid" => $record->pid,
238
                         "pid" => $record->pid,
206
                         "name" => $record->name,
239
                         "name" => $record->name,
207
                         "info" => $record->info,
240
                         "info" => $record->info,
208
-                        "content" => $record->content,
241
+                        "summary" => $record->summary,
209
                         "api" => $data["api"],
242
                         "api" => $data["api"],
210
                         "fields" => $data["fields"]
243
                         "fields" => $data["fields"]
211
                     ]
244
                     ]

+ 5
- 1
manage-server/app/Models/Classify.php Просмотреть файл

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

+ 4
- 0
manage-server/database/migrations/2018_08_20_075456_create_classifies_table.php Просмотреть файл

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

Загрузка…
Отмена
Сохранить