code: public function getParentKeyName()
      {
          if ($this->getParentName()) {
              
              $func = $this->getParentName();
              $relat = $this->$func();
              
              /*
               * if (! $relat instanceof \Illuminate\Database\Eloquent\Relations\BelongsTo) {
               * $field = $relat->getForeignKey();
               * } else {
               * $field = 'id';
               * }
               */
              
              $field = $relat->getForeignKey();
              
              return $field;
          }
          
          return 'id';
      }
docs: Return parent key name
  
  @return string