input('id'); $server = $request->input('server'); $content = $request->input('content');; $photo = $request->input('photo'); $location = $request->input('location'); if ($id) { $serverInfo = ServerInfo::find($id); } else { $serverInfo = new Campaign; } if ($server && $content) { $serverInfo->server = $server; $serverInfo->content = $content; $serverInfo->photo = $photo; $serverInfo->location = $location; $serverInfo->save(); return Response()->json([ "status" => 0, "message" => "保存成功!" ]); } else { return Response()->json([ "status" => -1, "message" => "信息不能为空!" ]); } } /** * 获取某个记录 * @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": "/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": "/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 = ServerInfo::find($id); if ($record) { return Response()->json([ "status" => 0, "data" => [ "id" => $record->id, "server" => $record->server, "content" => $recore->content, "photo" => $recore->photo, "location" => $recore->location, "api" => $data["api"], "fields" => $data["fields"] ] ]); } return Response()->json([ "status" => -2, "message" => "不存在的记录!" ]); } else { return Response()->json([ "status" => -1, "message" => "id不能为空!" ]); } } /** * 每页20进行分页 * @param Request $request * @return mixed */ public function list(Request $request) { $top = ServerInfo::where("location", "top")->get(); $bottom = ServerInfo::where("location", "bottom")->first(); return Response()->json([ "top" => $top, "introduce" => "服务介绍", "bottom" => $bottom ]); } }