家政小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerInfoController.php 1.6KB

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