|
@@ -22,10 +22,11 @@ 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
|
+ $show = $request->input('show');
|
26
|
26
|
if ($id) {
|
27
|
27
|
$product = Product::find($id);
|
28
|
28
|
$product->status = $status;
|
|
29
|
+ $product->show = 0;
|
29
|
30
|
} else {
|
30
|
31
|
$product = new Product;
|
31
|
32
|
$product->status = 0;
|
|
@@ -38,7 +39,7 @@ class ProductController extends Controller
|
38
|
39
|
$product->color = $color;
|
39
|
40
|
$product->price = $price;
|
40
|
41
|
$product->classify = $classify;
|
41
|
|
- $product->location = $location;
|
|
42
|
+ $product->show = $show;
|
42
|
43
|
$product->save();
|
43
|
44
|
return Response()->json([
|
44
|
45
|
"status" => 0,
|
|
@@ -99,29 +100,20 @@ class ProductController extends Controller
|
99
|
100
|
*/
|
100
|
101
|
public function home(Request $request)
|
101
|
102
|
{
|
102
|
|
- $top = Product::where("location", "top")->limit(3)->get()->toArray();
|
103
|
|
- $bottom = Product::where("location", "bottom")->first();
|
|
103
|
+ $top = Product::where("show", 1)->orderBy("updated_at", "desc")->limit(3)->get()->toArray();
|
104
|
104
|
|
105
|
105
|
$tops = array_map(function ($t) {
|
106
|
106
|
return [
|
107
|
107
|
"id" => $t["id"],
|
108
|
108
|
"name" => $t["name"],
|
109
|
|
- "info" => $t["info"],
|
110
|
109
|
"photo" => $t["photo"],
|
111
|
110
|
"location" => $t["location"]
|
112
|
111
|
];
|
113
|
112
|
}, $top);
|
114
|
113
|
|
115
|
114
|
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
|
|
- ]
|
|
115
|
+ "data" => $tops,
|
|
116
|
+ "status" => 0,
|
125
|
117
|
]);
|
126
|
118
|
}
|
127
|
119
|
|