比如這控制器的代碼,不知道是否會影響后續(xù)請求.
public function getChannel(Request $request)
{
$channel = $request->post('channel');
$where = [];
$where[] = ['channel', '=', $channel];
$lists = CloseTidModel::field('type,tid')->where($where)->select();
return json(['code' => 0, 'msg' => 'ok', 'data' => $lists]);
}
ai給的答案是,當(dāng)控制器復(fù)用時(shí),建議避免在控制器中直接調(diào)用模型的靜態(tài)方法。相反,可以通過實(shí)例化模型對象來調(diào)用其實(shí)例方法,以確保每個(gè)請求都有自己獨(dú)立的模型實(shí)例。