get('type'); $lang = $request->get('lang', 'en'); $typepArr = [ 'ann' => 1, 'faq' => 2, 'tut' => 3, ]; $type = $typepArr[$typestr] ?? 1; $article = Articles::where(['type' => $type])->where(['lang' => $lang])->orderBy('id', 'desc')->first(); if (is_null($article)) { header('Content-type: application/json'); $data = [ 'title' => "暂无内容", 'content' => "暂无内容", ]; echo json_encode(['code' => 0, 'msg' => '','data'=>$data], 256); exit; } else { header('Content-type: application/json'); $data = [ 'title' => $article->title, 'content' => $article->content, ]; echo json_encode(['code' => 0, 'msg' => '', 'data' => $data], 256); exit; } } }