original_string: protected function resolveNestedRelations($data):array
      {
          if (is_null($data)) {
              return [];
          }
  
          $data = $data instanceof Model ? [$data] : $data;
  
          return collect($data)->flatMap(function ($model) {
              $relations = collect($model->getRelations());
  
              return $relations->keys()->merge($relations->flatMap(function ($relation, $key) {
                  return collect($this->resolveNestedRelations($relation))->map(function ($nestedRelation) use ($key) {
                      return $key . '.' . $nestedRelation;
                  });
              }));
          })->unique()->toArray();
      }
code: protected function resolveNestedRelations($data):array
      {
          if (is_null($data)) {
              return [];
          }
  
          $data = $data instanceof Model ? [$data] : $data;
  
          return collect($data)->flatMap(function ($model) {
              $relations = collect($model->getRelations());
  
              return $relations->keys()->merge($relations->flatMap(function ($relation, $key) {
                  return collect($this->resolveNestedRelations($relation))->map(function ($nestedRelation) use ($key) {
                      return $key . '.' . $nestedRelation;
                  });
              }));
          })->unique()->toArray();
      }
code_tokens: protected function resolveNestedRelations ( $ data ) : array { if ( is_null ( $ data ) ) { return [ ] ; } $ data = $ data instanceof Model ? [ $ data ] : $ data ; return collect ( $ data ) -> flatMap ( function ( $ model ) { $ relations = collect ( $ model -> getRelations ( ) ) ; return $ relations -> keys ( ) -> merge ( $ relations -> flatMap ( function ( $ relation , $ key ) { return collect ( $ this -> resolveNestedRelations ( $ relation ) ) -> map ( function ( $ nestedRelation ) use ( $ key ) { return $ key . '.' . $ nestedRelation ; } ) ; } ) ) ; } ) -> unique ( ) -> toArray ( ) ; }
docstring: Resolve eager loaded relations from the model including any nested relations.
  
  @param  \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model $data
  @return array
docstring_tokens: Resolve eager loaded relations from the model including any nested relations .