~~~ /** * 处理分页 * @param $request * @return array */ static function executePage($request): array { $page = $request->input("page") ?? 1; $limit = $request->input("limit") ?? 15; $offset = ($page - 1) * $limit; return [(int)$page,(int)$limit,$offset]; } ~~~ ~~~ //处理入库参数 $data['account']= $request->input('account') ?? null; $data['password'] = $request->input('password') ?? null; $data['phone'] = $request->input('phone') ?? null; $data['nickname'] = $request->input('nickname') ?? null; $data['password'] = empty($data['password']) ? null : md5($data['password']); return unset_null($data); function unset_null($arr){ foreach($arr as $k=>$v){ if($v === null){ unset($arr[$k]); } } return $arr; } ~~~ ~~~ function successMsg($data=null, string $msg="success"): Response { return json(['code' => 200,'msg' => $msg,'data' => $data]); } function errorMsg(string $msg="error", int $code = -1,$data=null): Response { return json(['code' => $code,'msg' => $msg,'data' => $data]); } function noticeMsg($code=200,$msg="success",$data=null): array { return ['code' => $code,'msg' => $msg,'data' => $data]; } ~~~