家政小程序
Ви не можете вибрати більше 25 тем Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ClassifyController.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Models\Classify;
  5. class ClassifyController extends Controller
  6. {
  7. public function list(Request $request)
  8. {
  9. return Classify::paginate(100);
  10. }
  11. /**
  12. * 获取某个记录
  13. * @param Request $request
  14. * @param $id
  15. * @return \Illuminate\Http\JsonResponse
  16. */
  17. public function get(Request $request, $id)
  18. {
  19. $id = $request->route("id");
  20. $fields_josn = "";
  21. if($id == 6) {
  22. $fields_josn ='{
  23. "id": 6,
  24. "api": "/api/maternity_matron_order/store",
  25. "fields": [
  26. {
  27. "name": "level",
  28. "name_cn": "一价全包",
  29. "input_group": [
  30. {
  31. "type": "radio",
  32. "value": "8800(初级月嫂)"
  33. },
  34. {
  35. "type": "radio",
  36. "value": "9800(普通月嫂)"
  37. },
  38. {
  39. "type": "radio",
  40. "value": "12800(高级月嫂)"
  41. },
  42. {
  43. "type": "radio",
  44. "value": "15800(金牌月嫂)"
  45. },
  46. {
  47. "type": "radio",
  48. "value": "18800(特级月嫂)"
  49. }
  50. ]
  51. }
  52. ]
  53. }';
  54. } else {
  55. $fields_josn = '{
  56. "id": 7,
  57. "api": "/api/housekeeper_order/store",
  58. "fields": [
  59. {
  60. "name": "contents",
  61. "name_cn": "服务内容",
  62. "input_group": [
  63. {
  64. "type": "radio",
  65. "value": "保洁"
  66. },
  67. {
  68. "type": "radio",
  69. "value": "婴儿看护"
  70. },
  71. {
  72. "type": "radio",
  73. "value": "老人看护"
  74. },
  75. {
  76. "type": "radio",
  77. "value": "全护理老人"
  78. },
  79. {
  80. "type": "radio",
  81. "value": "空调清洗"
  82. },
  83. {
  84. "type": "radio",
  85. "value": "冰箱清洗"
  86. },
  87. {
  88. "type": "radio",
  89. "value": "抽油烟机清洗"
  90. },
  91. {
  92. "type": "radio",
  93. "value": "家庭除螨"
  94. },
  95. {
  96. "type": "radio",
  97. "value": "开荒清洁"
  98. },
  99. {
  100. "type": "radio",
  101. "value": "催乳"
  102. },
  103. {
  104. "type": "radio",
  105. "value": "产后康复"
  106. }
  107. ]
  108. },
  109. {
  110. "name": "people_num",
  111. "name_cn": "人口数量",
  112. "input_group": [
  113. {
  114. "type": "radio",
  115. "value": "1-2人"
  116. },
  117. {
  118. "type": "radio",
  119. "value": "3-4人"
  120. },
  121. {
  122. "type": "radio",
  123. "value": "5-6人"
  124. },
  125. {
  126. "type": "radio",
  127. "value": "6人以上"
  128. }
  129. ]
  130. },
  131. {
  132. "name": "area",
  133. "name_cn": "房屋面积",
  134. "input_group": [
  135. {
  136. "type": "radio",
  137. "value": "60平以下"
  138. },
  139. {
  140. "type": "radio",
  141. "value": "60-120平"
  142. },
  143. {
  144. "type": "radio",
  145. "value": "120-160平"
  146. },
  147. {
  148. "type": "radio",
  149. "value": "160-200平"
  150. },
  151. {
  152. "type": "radio",
  153. "value": "200平以上"
  154. }
  155. ]
  156. },
  157. {
  158. "name": "server_time",
  159. "name_cn": "服务时间",
  160. "input_group": [
  161. {
  162. "type": "radio",
  163. "value": "全白天"
  164. },
  165. {
  166. "type": "radio",
  167. "value": "住家"
  168. }
  169. ]
  170. },
  171. {
  172. "name": "rest",
  173. "name_cn": "休息安排",
  174. "input_group": [
  175. {
  176. "type": "radio",
  177. "value": "每周单休"
  178. },
  179. {
  180. "type": "radio",
  181. "value": "每周双休"
  182. }
  183. ]
  184. }
  185. ]
  186. }';
  187. }
  188. $data = json_decode($fields_josn, true);
  189. $data["id"] = $id;
  190. if ($id) {
  191. $record = Classify::find($id);
  192. if ($record) {
  193. return Response()->json([
  194. "status" => 0,
  195. "data" => [
  196. "id" => $record->id,
  197. "pid" => $record->pid,
  198. "name" => $record->name,
  199. "info" => $record->info,
  200. "content" => $record->content,
  201. "api" => $data["api"],
  202. "fields" => $data["fields"]
  203. ]
  204. ]);
  205. }
  206. return Response()->json([
  207. "status" => -2,
  208. "message" => "不存在的记录!"
  209. ]);
  210. } else {
  211. return Response()->json([
  212. "status" => -1,
  213. "message" => "id不能为空!"
  214. ]);
  215. }
  216. }
  217. }