original_string: public function scopeWithRelations(Builder $builder, $relations = null)
      {
          $with = [];
          foreach ($this->getWithRelationsList($relations) as $relation) {
              list($relation, $scope) = $this->_parseRelation($relation);
  
              if ($this->isWithableRelation($builder, $relation)) {
                  if ($scope) {
                      $with[$relation] = function ($query) use ($scope) {
                          $query->$scope();
                      };
                  } else {
                      $with[] = $relation;
                  }
              }
          }
          $builder->with($with);
      }
code: public function scopeWithRelations(Builder $builder, $relations = null)
      {
          $with = [];
          foreach ($this->getWithRelationsList($relations) as $relation) {
              list($relation, $scope) = $this->_parseRelation($relation);
  
              if ($this->isWithableRelation($builder, $relation)) {
                  if ($scope) {
                      $with[$relation] = function ($query) use ($scope) {
                          $query->$scope();
                      };
                  } else {
                      $with[] = $relation;
                  }
              }
          }
          $builder->with($with);
      }
code_tokens: public function scopeWithRelations ( Builder $ builder , $ relations = null ) { $ with = [ ] ; foreach ( $ this -> getWithRelationsList ( $ relations ) as $ relation ) { list ( $ relation , $ scope ) = $ this -> _parseRelation ( $ relation ) ; if ( $ this -> isWithableRelation ( $ builder , $ relation ) ) { if ( $ scope ) { $ with [ $ relation ] = function ( $ query ) use ( $ scope ) { $ query -> $ scope ( ) ; } ; } else { $ with [ ] = $ relation ; } } } $ builder -> with ( $ with ) ; }
docstring: Add eager loaded relations.
  
  @param Builder $builder query builder
  @param array $relations list of relations to be loaded
docstring_tokens: Add eager loaded relations .