code: public function checkAcceptHeader(Request $request)
      {
          $headers = $request->getAcceptableContentTypes();
  
          if (array_intersect($headers, ['application/json', 'text/json'])) {
              return 'json';
          } elseif (array_intersect($headers, ['application/xml', 'text/xml'])) {
              return 'xml';
          }
  
          return $this->defaultAcceptType;
      }
docs: Returns acceptance type based on given request.
  
  @param Request $request
  
  @return string