original_string: protected function hasNullableForeignKeys(Relation $relation, Model $model = null, array $keys = null)
      {
          if (null === $keys) {
              $keys = $this->getForeignKeyNamesForRelation($relation);
          }
  
          if ( ! count($keys)) return false;
  
          // Determine the model on which the foreign key is stored
  
          if (null === $model) {
  
              if (    $relation instanceof BelongsTo
                  ||  $relation instanceof MorphTo
                  ||  is_a($relation, '\\Znck\\Eloquent\\Relations\\BelongsToThrough', true)
              ) {
                  $model = $this->model;
  
              } elseif (  $relation instanceof HasOne
                      ||  $relation instanceof HasMany
                      ||  $relation instanceof BelongsToMany
              ) {
                  $model = $relation->getRelated();
              }
          }
  
          if ( ! $model) {
              throw new RuntimeException('No model could be determined for nullable foreign key check');
          }
  
          $info = $this->getModelInformation($model);
  
          // We can use the information to determine whether the model has nullable foreign key
          if ($info) {
  
              // For all relations, the first key value must be checked
              $attribute = array_get($info->attributes, $this->normalizeForeignKey(head($keys)));
              $nullable  = $attribute ? $attribute->nullable : false;
  
              // For morph relation types, we must also check the type column
              if (    $nullable
                  &&  count($keys) > 1
                  &&  (   $relation instanceof MorphTo
                      ||  $relation instanceof MorphOne
                      ||  $relation instanceof MorphMany
                      )
              ) {
                  $attribute = array_get($info->attributes, $this->normalizeForeignKey(array_values($keys)[1]));
                  $nullable  = $attribute ? $attribute->nullable : false;
              }
  
              return $nullable;
          }
  
          // We must somehow determine whether the foreign key is nullable on this
          // model without having information about it.
  
          // todo: for now, assume false, use the 'nullable_keys' option to configure this instead
  
          return false;
      }
code: protected function hasNullableForeignKeys(Relation $relation, Model $model = null, array $keys = null)
      {
          if (null === $keys) {
              $keys = $this->getForeignKeyNamesForRelation($relation);
          }
  
          if ( ! count($keys)) return false;
  
          // Determine the model on which the foreign key is stored
  
          if (null === $model) {
  
              if (    $relation instanceof BelongsTo
                  ||  $relation instanceof MorphTo
                  ||  is_a($relation, '\\Znck\\Eloquent\\Relations\\BelongsToThrough', true)
              ) {
                  $model = $this->model;
  
              } elseif (  $relation instanceof HasOne
                      ||  $relation instanceof HasMany
                      ||  $relation instanceof BelongsToMany
              ) {
                  $model = $relation->getRelated();
              }
          }
  
          if ( ! $model) {
              throw new RuntimeException('No model could be determined for nullable foreign key check');
          }
  
          $info = $this->getModelInformation($model);
  
          // We can use the information to determine whether the model has nullable foreign key
          if ($info) {
  
              // For all relations, the first key value must be checked
              $attribute = array_get($info->attributes, $this->normalizeForeignKey(head($keys)));
              $nullable  = $attribute ? $attribute->nullable : false;
  
              // For morph relation types, we must also check the type column
              if (    $nullable
                  &&  count($keys) > 1
                  &&  (   $relation instanceof MorphTo
                      ||  $relation instanceof MorphOne
                      ||  $relation instanceof MorphMany
                      )
              ) {
                  $attribute = array_get($info->attributes, $this->normalizeForeignKey(array_values($keys)[1]));
                  $nullable  = $attribute ? $attribute->nullable : false;
              }
  
              return $nullable;
          }
  
          // We must somehow determine whether the foreign key is nullable on this
          // model without having information about it.
  
          // todo: for now, assume false, use the 'nullable_keys' option to configure this instead
  
          return false;
      }
code_tokens: protected function hasNullableForeignKeys ( Relation $ relation , Model $ model = null , array $ keys = null ) { if ( null === $ keys ) { $ keys = $ this -> getForeignKeyNamesForRelation ( $ relation ) ; } if ( ! count ( $ keys ) ) return false ; // Determine the model on which the foreign key is stored if ( null === $ model ) { if ( $ relation instanceof BelongsTo || $ relation instanceof MorphTo || is_a ( $ relation , '\\Znck\\Eloquent\\Relations\\BelongsToThrough' , true ) ) { $ model = $ this -> model ; } elseif ( $ relation instanceof HasOne || $ relation instanceof HasMany || $ relation instanceof BelongsToMany ) { $ model = $ relation -> getRelated ( ) ; } } if ( ! $ model ) { throw new RuntimeException ( 'No model could be determined for nullable foreign key check' ) ; } $ info = $ this -> getModelInformation ( $ model ) ; // We can use the information to determine whether the model has nullable foreign key if ( $ info ) { // For all relations, the first key value must be checked $ attribute = array_get ( $ info -> attributes , $ this -> normalizeForeignKey ( head ( $ keys ) ) ) ; $ nullable = $ attribute ? $ attribute -> nullable : false ; // For morph relation types, we must also check the type column if ( $ nullable && count ( $ keys ) > 1 && ( $ relation instanceof MorphTo || $ relation instanceof MorphOne || $ relation instanceof MorphMany ) ) { $ attribute = array_get ( $ info -> attributes , $ this -> normalizeForeignKey ( array_values ( $ keys ) [ 1 ] ) ) ; $ nullable = $ attribute ? $ attribute -> nullable : false ; } return $ nullable ; } // We must somehow determine whether the foreign key is nullable on this // model without having information about it. // todo: for now, assume false, use the 'nullable_keys' option to configure this instead return false ; }
docstring: Returns whether a relation's related model has nullable foreign keys.
  
  @param Relation      $relation
  @param Model         $model     if the model with the keys should not be resolved, pass it in
  @param string[]|null $keys      if already known, the foreign keys for the relation
  @return bool
docstring_tokens: Returns whether a relation s related model has nullable foreign keys .