input("top1"); $top2 = $request->input("top2"); $top3 = $request->input("top3"); $bottom = $request->input("bottom"); $introduce = $request->input("introduce"); if($top1 && $top2 && $top3 && $bottom && $introduce) { $homePage = HomePage::find(1); $homePage->top1 = $top1; $homePage->top2 = $top2; $homePage->top3 = $top3; $homePage->bottom = $bottom; $homePage->introduce = $introduce; $homePage->save(); return response()->json([ "status" => 0, "message" => '修改成功' ]); } else { return Response()->json([ "status" => -1, "message" => "信息不能为空!" ]); } } /** * 每页20进行分页 * @param Request $request * @return mixed */ public function home(Request $request) { $homePage = HomePage::find(1); $top1 = HomePage::find($homePage->top1); $top2 = HomePage::find($homePage->top2); $top3 = HomePage::find($homePage->top3); $bottom = HomePage::find($homePage->bottom); $introduce = HomePage::find($homePage->introduce); return Response()->json([ "top" => [ [ "id" => $top1["id"], "server" => $top1["server"], "content" => $top1["content"], "photo" => $top1["photo"], ], [ "id" => $top2["id"], "server" => $top2["server"], "content" => $top2["content"], "photo" => $top2["photo"], ], [ "id" => $top3["id"], "server" => $top3["server"], "content" => $top3["content"], "photo" => $top3["photo"], ] ], "introduce" => $introduce, "bottom" => [ "id" => $bottom["id"], "server" => $bottom["server"], "content" => $bottom["content"], "photo" => $bottom["photo"], ] ]); } /** * 获取某个记录 * @param Request $request * @param $id * @return \Illuminate\Http\JsonResponse */ public function get(Request $request, $id) { $id = $request->route("id"); $fields_josn = ""; if($id == 6) { $fields_josn ='{ "id": 6, "api": "maternity_matron_order/store", "fields": [ { "name": "level", "name_cn": "一价全包", "input_group": [ { "type": "radio", "value": "8800(初级月嫂)" }, { "type": "radio", "value": "9800(普通月嫂)" }, { "type": "radio", "value": "12800(高级月嫂)" }, { "type": "radio", "value": "15800(金牌月嫂)" }, { "type": "radio", "value": "18800(特级月嫂)" } ] } ] }'; } else { $fields_josn = '{ "id": 7, "api": "housekeeper_order/store", "fields": [ { "name": "contents", "name_cn": "服务内容", "input_group": [ { "type": "radio", "value": "保洁" }, { "type": "radio", "value": "婴儿看护" }, { "type": "radio", "value": "老人看护" }, { "type": "radio", "value": "全护理老人" }, { "type": "radio", "value": "空调清洗" }, { "type": "radio", "value": "冰箱清洗" }, { "type": "radio", "value": "抽油烟机清洗" }, { "type": "radio", "value": "家庭除螨" }, { "type": "radio", "value": "开荒清洁" }, { "type": "radio", "value": "催乳" }, { "type": "radio", "value": "产后康复" } ] }, { "name": "people_num", "name_cn": "人口数量", "input_group": [ { "type": "radio", "value": "1-2人" }, { "type": "radio", "value": "3-4人" }, { "type": "radio", "value": "5-6人" }, { "type": "radio", "value": "6人以上" } ] }, { "name": "area", "name_cn": "房屋面积", "input_group": [ { "type": "radio", "value": "60平以下" }, { "type": "radio", "value": "60-120平" }, { "type": "radio", "value": "120-160平" }, { "type": "radio", "value": "160-200平" }, { "type": "radio", "value": "200平以上" } ] }, { "name": "server_time", "name_cn": "服务时间", "input_group": [ { "type": "radio", "value": "全白天" }, { "type": "radio", "value": "住家" } ] }, { "name": "rest", "name_cn": "休息安排", "input_group": [ { "type": "radio", "value": "每周单休" }, { "type": "radio", "value": "每周双休" } ] } ] }'; } $data = json_decode($fields_josn, true); $data["id"] = $id; if ($id) { $record = Classify::find($id); if ($record) { return Response()->json([ "status" => 0, "data" => [ "id" => $record->id, "pid" => $record->pid, "name" => $record->name, "info" => $record->info, "content" => $record->summary, "photo" => $record->photo, "api" => $data["api"], "fields" => $data["fields"], "type" => $record->name, ] ]); } return Response()->json([ "status" => -2, "message" => "不存在的记录!" ]); } else { return Response()->json([ "status" => -1, "message" => "id不能为空!" ]); } } /** * @param Request $request * @param $id * @return \Illuminate\Http\JsonResponse */ public function server_content(Request $request, $id) { $id = $request->route("id"); if ($id) { $record = Classify::find($id); if ($record) { return Response()->json([ "status" => 0, "data" => [ "id" => $record->id, "server" => $record->server, "content" => $record->content, "photo" => $record->photo, "location" => $record->location, ] ]); } return Response()->json([ "status" => -2, "message" => "不存在的记录!" ]); } else { return Response()->json([ "status" => -1, "message" => "id不能为空!" ]); } } /** * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function store(Request $request) { $id = $request->input('id'); $pid = $request->input('pid'); $name = $request->input('name'); $info = $request->input('info'); $summary = $request->input('summary'); $server = $request->input('server'); $content = $request->input('content'); $photo = $request->input('photo'); $location = $request->input('location'); if ($id) { $classify = Classify::find($id); } else { $classify = new Classify; } if ($pid && $name && $info && $summary && $server && $content && $photo && $location) { $classify->pid = $pid; $classify->name = $name; $classify->info = $info; $classify->summary = $summary; $classify->server = $server; $classify->content = $content; $classify->photo = $photo; $classify->location = $location; $classify->save(); return Response()->json([ "status" => 0, "message" => "保存成功!" ]); } else { return Response()->json([ "status" => -1, "message" => "信息不能为空!" ]); } } }