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

一只萌萌小番薯
TA貢獻1795條經(jīng)驗 獲得超7個贊
為什么不將其添加到數(shù)據(jù)中呢?
$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 關(guān)注
- 154 瀏覽
添加回答
舉報
0/150
提交
取消