public function respond(int $statusCode = null, array $headers = []):JsonResponse
    {
        if (! is_null($statusCode)) {
            $this->setStatus($statusCode);
        }

        $data = $this->toArray();
        $data = $this->includeStatusCode($data);
        $data = $this->includeSuccessFlag($data);

        return $this->responseFactory->json($data, $this->statusCode, $headers);
    }
public function respond(int $statusCode = null, array $headers = []):JsonResponse
    {
        if (! is_null($statusCode)) {
            $this->setStatus($statusCode);
        }

        $data = $this->toArray();
        $data = $this->includeStatusCode($data);
        $data = $this->includeSuccessFlag($data);

        return $this->responseFactory->json($data, $this->statusCode, $headers);
    }
public function respond ( int $ statusCode = null , array $ headers = [ ] ) : JsonResponse { if ( ! is_null ( $ statusCode ) ) { $ this -> setStatus ( $ statusCode ) ; } $ data = $ this -> toArray ( ) ; $ data = $ this -> includeStatusCode ( $ data ) ; $ data = $ this -> includeSuccessFlag ( $ data ) ; return $ this -> responseFactory -> json ( $ data , $ this -> statusCode , $ headers ) ; }
Serialize the data and wrap it in a JSON response object.

@param  int|null $statusCode
@param  array    $headers
@return \Illuminate\Http\JsonResponse
Serialize the data and wrap it in a JSON response object .