我正在嘗試通過我的API函數返回響應,并且效果很好。但是,現在,我正在嘗試在同一控制器中執行公共功能,同時還返回響應。這可能嗎?return response()->json($success);但是我想要的是將上面的響應與此一起發送;return $this->sendSMS($data);($ data)已經預定義。有什么方法可以做到這一點?
1 回答

一只萌萌小番薯
TA貢獻1795條經驗 獲得超7個贊
為什么不將其添加到數據中呢?
$dataWithResponse = compact('data', 'response');
try {
$this->sendSMS($dataWithResponse);
} catch(/Exception $e) {
// Somehow handle exception
echo $e->getMessage();
return response()->json($success);
}
return response()->json($success);
- 1 回答
- 0 關注
- 161 瀏覽
添加回答
舉報
0/150
提交
取消