original_string: public function getReferencesForModelMetaReference(ModelMetaReferenceInterface $referenceData, $search = null)
      {
          $modelClass = $referenceData->model();
  
          $query = $this->getQueryBuilderForModelClass($modelClass);
  
          $this->applySortingToQueryBuilder(
              $query,
              $referenceData->source(),
              $referenceData->sortDirection(),
              $referenceData->sortStrategy()
          );
  
          if (null !== $search) {
              $this->applySearchTermFilterToQueryBuilder($query, $referenceData->target(), $search);
          }
  
          // If set, apply an (extra) contextual modification to the query builder
          if ($referenceData->contextStrategy()) {
              $this->applyContextStrategyToQueryBuilder(
                  $query,
                  $referenceData->contextStrategy(),
                  $referenceData->parameters()
              );
          }
  
          /** @var Collection|Model[] $models */
          $models = $query->get();
  
          // Get references for query results, keyed by primary key
          $references = [];
  
          foreach ($models as $model) {
  
              $references[ $model->getKey() ] = $this->getReferenceForModel(
                  $model,
                  $referenceData->strategy(),
                  $referenceData->source()
              );
          }
  
          return new Collection($references);
      }
code: public function getReferencesForModelMetaReference(ModelMetaReferenceInterface $referenceData, $search = null)
      {
          $modelClass = $referenceData->model();
  
          $query = $this->getQueryBuilderForModelClass($modelClass);
  
          $this->applySortingToQueryBuilder(
              $query,
              $referenceData->source(),
              $referenceData->sortDirection(),
              $referenceData->sortStrategy()
          );
  
          if (null !== $search) {
              $this->applySearchTermFilterToQueryBuilder($query, $referenceData->target(), $search);
          }
  
          // If set, apply an (extra) contextual modification to the query builder
          if ($referenceData->contextStrategy()) {
              $this->applyContextStrategyToQueryBuilder(
                  $query,
                  $referenceData->contextStrategy(),
                  $referenceData->parameters()
              );
          }
  
          /** @var Collection|Model[] $models */
          $models = $query->get();
  
          // Get references for query results, keyed by primary key
          $references = [];
  
          foreach ($models as $model) {
  
              $references[ $model->getKey() ] = $this->getReferenceForModel(
                  $model,
                  $referenceData->strategy(),
                  $referenceData->source()
              );
          }
  
          return new Collection($references);
      }
code_tokens: public function getReferencesForModelMetaReference ( ModelMetaReferenceInterface $ referenceData , $ search = null ) { $ modelClass = $ referenceData -> model ( ) ; $ query = $ this -> getQueryBuilderForModelClass ( $ modelClass ) ; $ this -> applySortingToQueryBuilder ( $ query , $ referenceData -> source ( ) , $ referenceData -> sortDirection ( ) , $ referenceData -> sortStrategy ( ) ) ; if ( null !== $ search ) { $ this -> applySearchTermFilterToQueryBuilder ( $ query , $ referenceData -> target ( ) , $ search ) ; } // If set, apply an (extra) contextual modification to the query builder if ( $ referenceData -> contextStrategy ( ) ) { $ this -> applyContextStrategyToQueryBuilder ( $ query , $ referenceData -> contextStrategy ( ) , $ referenceData -> parameters ( ) ) ; } /** @var Collection|Model[] $models */ $ models = $ query -> get ( ) ; // Get references for query results, keyed by primary key $ references = [ ] ; foreach ( $ models as $ model ) { $ references [ $ model -> getKey ( ) ] = $ this -> getReferenceForModel ( $ model , $ referenceData -> strategy ( ) , $ referenceData -> source ( ) ) ; } return new Collection ( $ references ) ; }
docstring: Returns references for models by meta reference data, keyed by the model keys.
  
  @param ModelMetaReferenceInterface $referenceData
  @param string|null                 $search           optional search string to limit results
  @return Collection   keyed by model key (or class:key)
docstring_tokens: Returns references for models by meta reference data keyed by the model keys .