|
@@ -22,6 +22,7 @@ class ProductController extends Controller
|
22
|
22
|
$color = $request->input('color');
|
23
|
23
|
$price = $request->input('price');
|
24
|
24
|
$status = $request->input('status');
|
|
25
|
+ $location = $request->input('location');
|
25
|
26
|
if ($id) {
|
26
|
27
|
$product = Product::find($id);
|
27
|
28
|
$product->status = $status;
|
|
@@ -37,6 +38,7 @@ class ProductController extends Controller
|
37
|
38
|
$product->color = $color;
|
38
|
39
|
$product->price = $price;
|
39
|
40
|
$product->classify = $classify;
|
|
41
|
+ $product->location = $location;
|
40
|
42
|
$product->save();
|
41
|
43
|
return Response()->json([
|
42
|
44
|
"status" => 0,
|
|
@@ -90,4 +92,37 @@ class ProductController extends Controller
|
90
|
92
|
]);
|
91
|
93
|
}
|
92
|
94
|
|
|
95
|
+ /**
|
|
96
|
+ * 每页20进行分页
|
|
97
|
+ * @param Request $request
|
|
98
|
+ * @return mixed
|
|
99
|
+ */
|
|
100
|
+ public function home(Request $request)
|
|
101
|
+ {
|
|
102
|
+ $top = Product::where("location", "top")->limit(3)->get()->toArray();
|
|
103
|
+ $bottom = Product::where("location", "bottom")->first();
|
|
104
|
+
|
|
105
|
+ $tops = array_map(function ($t) {
|
|
106
|
+ return [
|
|
107
|
+ "id" => $t["id"],
|
|
108
|
+ "name" => $t["name"],
|
|
109
|
+ "info" => $t["info"],
|
|
110
|
+ "photo" => $t["photo"],
|
|
111
|
+ "location" => $t["location"]
|
|
112
|
+ ];
|
|
113
|
+ }, $top);
|
|
114
|
+
|
|
115
|
+ return Response()->json([
|
|
116
|
+ "top" => $tops,
|
|
117
|
+ "introduce" => "产品介绍",
|
|
118
|
+ "bottom" => [
|
|
119
|
+ "id" => $bottom["id"],
|
|
120
|
+ "name" => $bottom["name"],
|
|
121
|
+ "info" => $bottom["info"],
|
|
122
|
+ "photo" => $bottom["photo"],
|
|
123
|
+ "location" => $bottom["location"]
|
|
124
|
+ ]
|
|
125
|
+ ]);
|
|
126
|
+ }
|
|
127
|
+
|
93
|
128
|
}
|