Reputation: 552
I'm trying to return a response via my API function and it works just fine. However, right now, I'm trying to execute a public function in the same controller whilst also returning a response. Is this possible?
return response()->json($success);
But what I want is to send the above response together with this;
return $this->sendSMS($data);
($data) has been predefined already.
Are there any ways to do this?
Upvotes: 3
Views: 1067
Reputation: 1427
Why don't you just add it to data?
$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);
Upvotes: 1