code: protected function getRelation($record, $key)
      {
          $relation = $record->{$key}();
  
          if (!$relation || !$this->acceptRelation($relation)) {
              throw new RuntimeException(sprintf(
                  'JSON API relation %s cannot be used for an Eloquent %s relation.',
                  class_basename($this),
                  class_basename($relation)
              ));
          }
  
          return $relation;
      }
docs: Get the relation from the model.
  
  @param Model $record
  @param string $key
  @return Relation|Builder