-
慕哥9229398
您只需将别名与获取选择一起传递即可->get(['id','name','begin_date AS start_date', 'end_date AS end_date']);
-
拉莫斯之舞
你可以像这样写Term::whereDate('begin_date', '>=', $start)
->whereDate('end_date', '<=', $end)
->get(['id','name','begin_date AS start_date', 'end_date As finish_date']);select或者通过在方法中编辑它Term::whereDate('begin_date', '>=', $start)
->whereDate('end_date', '<=', $end)
->select('id','name','begin_date AS start_date', 'end_date As finish_date')
->get();
-
Smart猫小萌
您可以在查询的 get 方法中命名列。尝试这个:$data = Term::whereDate('begin_date', '>=', $start)->whereDate('end_date', '<=', $end)->get(['id','name','begin_date AS start_date', 'end_date AS finish_date']);
-
猛跑小猪
您是否刚刚尝试替换您粘贴的代码中的那些列?$data = Term::whereDate('start_date', '>=', $start)->whereDate('finish_date', '<=', $end)->get(['id','name','start_date', 'finish_date']);