家政小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ServerInfoController.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Models\ServerInfo;
  5. class ServerInfoController extends Controller
  6. {
  7. /**
  8. * 创建活动
  9. * @param Request $request
  10. * @return \Illuminate\Http\JsonResponse
  11. */
  12. public function store(Request $request)
  13. {
  14. $id = $request->input('id');
  15. $server = $request->input('server');
  16. $content = $request->input('content');;
  17. $photo = $request->input('photo');
  18. $location = $request->input('location');
  19. if ($id) {
  20. $serverInfo = ServerInfo::find($id);
  21. } else {
  22. $serverInfo = new Campaign;
  23. }
  24. if ($server && $content) {
  25. $serverInfo->server = $server;
  26. $serverInfo->content = $content;
  27. $serverInfo->photo = $photo;
  28. $serverInfo->location = $location;
  29. $serverInfo->save();
  30. return Response()->json([
  31. "status" => 0,
  32. "message" => "保存成功!"
  33. ]);
  34. } else {
  35. return Response()->json([
  36. "status" => -1,
  37. "message" => "信息不能为空!"
  38. ]);
  39. }
  40. }
  41. /**
  42. * 每页20进行分页
  43. * @param Request $request
  44. * @return mixed
  45. */
  46. public function list(Request $request)
  47. {
  48. $top = ServerInfo::where("location", "top")->get();
  49. $bottom = ServerInfo::where("location", "bottom")->firet();
  50. return Response()->json([
  51. "top" => $top,
  52. "introduce" => "服务介绍",
  53. "bottom" => $bottom
  54. ]);
  55. }
  56. }