apiService = $apiService; $this->shorty = new Shorty(config("app.domain")); } /** * 短地址自动跳转 */ public function index(Request $request) { $plink = $request->route("plink", ""); //详情页面分配的地址 $id = $this->shorty->decode($plink); $info = UrlsFacade::findOneById($id, "url"); if (empty($info['url'])) { abort(404); } UrlsFacade::incrementBy(["id" => $id], "hits"); $ip = getClientIp(); $uvInfo = UrlsFacade::findOneLogInfo([ 'urls_id' => $id, 'ip' => $ip ], 'id'); if (empty($uvInfo['id'])) { UrlsFacade::incrementBy(["id" => $id], "uv"); } UrlsFacade::addLog($id, $ip); $this->shorty->redirect($info['url']); } }