标准的json返回,带状态码
xuexi 2025-08-08 10:06:42 发表在:PHP 查看数:43
public function list(Request $request){
        // $projectId = $request->get('q');
        // $a[]=['id'=>'null','text'=>'无'];
        // $a[] = Scsym::where('pc_id',$projectId)->get(['id', DB::raw('code as text')]);
        // return $a;
      //  $token_jm = $request->get('token_jm');//接收中间件产生的参数   
        $a  = DB::table('cb_xunjian_xjjh')->select('title as title','xjrw_id as stage','a as proType','b as area','djbh as djbh','starttime as starttime','endtime as endtime','id as xjjh_id','jindu as jindu','weidu as weidu','maxjuli as maxjuli')->where('zt',null)
                 //  ->orderBy('release_date', 'desc')
                   ->orderBy('starttime', 'asc')->get();
        $b =  DB::table('cb_bumen')->select('name as proType')->get();   

         // 创建一个新的数组对象来包含这些数据
        $data = [
            'code'=>200,
            'message'=>'加载成功',
            'res1' => $a,
            'res2' => $b,
            'token_jm' => $request->get('token_jm')
         ];


    // $data = Xjrw::get()->toArray();
    return response()->json($data,200);  


    }
最近访问时间:2025-08-18 07:36:30
知识库:372条鸣谢:TAY  备案号:蜀ICP备2024090044号-2