I need to accept data from from SP. I calls SP from web API(laravel).
//get no reg from system
$response3 = $client->post($webapi_url . '/api/max_noreg', [
// 'json' => [
'form_params' => [
'tglreg' => '2020-07-20 00:00:00',
],
'cookies' => $cookieJar,
'headers' => [
'Accept' => 'application/json',
],
]);
dd($response3);
here's my SP
ALTER PROCEDURE [dbo].[spmcu_Reg_MaxNoRegByTglTrans]
@TglTrans datetime
AS
SELECT NoRegMax = IsNull(MAX(NoReg),'') FROM mcu_Reg
WHERE TglTrans = @TglTrans
here's my API controller
public function max_noreg(Request $request)
{
// $credentials = [
// 'tglreg' => $request->tglreg
// ];
// $tglst = '2020-07-19 00:00:00';
$referral_registers = DB::connection('as_api')
->select('EXEC spmcu_Reg_MaxNoRegByTglTrans ?',
array($request->tglreg));
return response()->json([
'success' => true,
'data' => $referral_registers
]);
}
and when i dd() the response, it return this
Response {#590 ▼ -reasonPhrase: "OK" -statusCode: 200 -headers: array:6 [▶] -headerNames: array:6 [▶] -protocol: "1.1" -stream: Stream {#582 ▶} }
and i want it return result from SP like example below
IDU2007200003
i've check my sql profiler, the logs like this
declare @p1 int set @p1=1 exec sp_prepexec @p1 output,N'@P1 nvarchar(4000)',N'EXEC spmcu_Reg_MaxNoRegByTglTrans @P1',N'2020-07-20 00:00:00' select @p1
pls help me to get my sp result and pass it to dd to test if i get the value
and below are my dump value
GuzzleHttp\Psr7\Response Object
(
[reasonPhrase:GuzzleHttp\Psr7\Response:private] => OK
[statusCode:GuzzleHttp\Psr7\Response:private] => 200
[headers:GuzzleHttp\Psr7\Response:private] => Array
(
[Host] => Array
(
[0] => 127.0.0.1:8000
)
[Date] => Array
(
[0] => Mon, 20 Jul 2020 05:36:30 GMT
[1] => Mon, 20 Jul 2020 05:36:30 GMT
)
[Connection] => Array
(
[0] => close
)
[X-Powered-By] => Array
(
[0] => PHP/7.2.19
)
[Cache-Control] => Array
(
[0] => no-cache, private
)
[Content-Type] => Array
(
[0] => application/json
)
)
[headerNames:GuzzleHttp\Psr7\Response:private] => Array
(
[host] => Host
[date] => Date
[connection] => Connection
[x-powered-by] => X-Powered-By
[cache-control] => Cache-Control
[content-type] => Content-Type
)
[protocol:GuzzleHttp\Psr7\Response:private] => 1.1
[stream:GuzzleHttp\Psr7\Response:private] => GuzzleHttp\Psr7\Stream Object
(
[stream:GuzzleHttp\Psr7\Stream:private] => Resource id #572
[size:GuzzleHttp\Psr7\Stream:private] =>
[seekable:GuzzleHttp\Psr7\Stream:private] => 1
[readable:GuzzleHttp\Psr7\Stream:private] => 1
[writable:GuzzleHttp\Psr7\Stream:private] => 1
[uri:GuzzleHttp\Psr7\Stream:private] => php://temp
[customMetadata:GuzzleHttp\Psr7\Stream:private] => Array
(
)
)
)
You can try like this, decode the response $response = json_decode($response3->getBody());
dd(response)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.