12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
-
- namespace App\Http\Controllers;
-
- use Illuminate\Http\Request;
- use App\Models\ServerInfo;
-
- class ServerInfoController extends Controller
- {
-
- /**
- * 创建活动
- * @param Request $request
- * @return \Illuminate\Http\JsonResponse
- */
- public function store(Request $request)
- {
- $id = $request->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" => "信息不能为空!"
- ]);
- }
- }
-
- /**
- * 每页20进行分页
- * @param Request $request
- * @return mixed
- */
- public function list(Request $request)
- {
- $top = ServerInfo::where("location", "top");
- $bottom = ServerInfo::where("location", "bottom");
- return Response()->json([
- "top" => $top,
- "introduce" => "服务介绍",
- "bottom" => $bottom
- ]);
- }
- }
|