protected function respond($data, $status = Response::HTTP_OK, $headers = []) : JsonResponse
    {
        if ($data instanceof ElementInterface) {
            $data = new Document($data);
        }

        if ($data instanceof Document) {
            $data = $data->toArray();
        }

        return response()->json($data, $status, $headers)
            ->header('Content-Type', ApiRequestHandler::CONTENT_TYPE);
    }
protected function respond($data, $status = Response::HTTP_OK, $headers = []) : JsonResponse
    {
        if ($data instanceof ElementInterface) {
            $data = new Document($data);
        }

        if ($data instanceof Document) {
            $data = $data->toArray();
        }

        return response()->json($data, $status, $headers)
            ->header('Content-Type', ApiRequestHandler::CONTENT_TYPE);
    }
protected function respond ( $ data , $ status = Response :: HTTP_OK , $ headers = [ ] ) : JsonResponse { if ( $ data instanceof ElementInterface ) { $ data = new Document ( $ data ) ; } if ( $ data instanceof Document ) { $ data = $ data -> toArray ( ) ; } return response ( ) -> json ( $ data , $ status , $ headers ) -> header ( 'Content-Type' , ApiRequestHandler :: CONTENT_TYPE ) ; }
respond json api

@param array|Document|ElementInterface $data
@param int $status
@param array $headers
@return JsonResponse
respond json api