original_string: protected function attachNew(array $records, array $current, $touch = true)
  	{
  		$changes = ['attached' => [], 'updated' => []];
  
  		foreach ($records as $id => $attributes) {
  			// If the ID is not in the list of existing pivot IDs, we will insert a new pivot
  			// record, otherwise, we will just update this existing record on this joining
  			// table, so that the developers will easily update these records pain free.
  			if (! in_array($id, $current)) {
  				$this->attach($id, $attributes, $touch);
  
  				$changes['attached'][] = is_numeric($id) ? (int) $id : (string) $id;
  			}
  
  			// Now we'll try to update an existing pivot record with the attributes that were
  			// given to the method. If the model is actually updated we will add it to the
  			// list of updated pivot records so we return them back out to the consumer.
  			elseif (count($attributes) > 0 &&
  				$this->updateExistingPivot($id, $attributes, $touch)) {
  				$changes['updated'][] = is_numeric($id) ? (int) $id : (string) $id;
  			}
  		}
  
  		return $changes;
  	}
code: protected function attachNew(array $records, array $current, $touch = true)
  	{
  		$changes = ['attached' => [], 'updated' => []];
  
  		foreach ($records as $id => $attributes) {
  			// If the ID is not in the list of existing pivot IDs, we will insert a new pivot
  			// record, otherwise, we will just update this existing record on this joining
  			// table, so that the developers will easily update these records pain free.
  			if (! in_array($id, $current)) {
  				$this->attach($id, $attributes, $touch);
  
  				$changes['attached'][] = is_numeric($id) ? (int) $id : (string) $id;
  			}
  
  			// Now we'll try to update an existing pivot record with the attributes that were
  			// given to the method. If the model is actually updated we will add it to the
  			// list of updated pivot records so we return them back out to the consumer.
  			elseif (count($attributes) > 0 &&
  				$this->updateExistingPivot($id, $attributes, $touch)) {
  				$changes['updated'][] = is_numeric($id) ? (int) $id : (string) $id;
  			}
  		}
  
  		return $changes;
  	}
code_tokens: protected function attachNew ( array $ records , array $ current , $ touch = true ) { $ changes = [ 'attached' => [ ] , 'updated' => [ ] ] ; foreach ( $ records as $ id => $ attributes ) { // If the ID is not in the list of existing pivot IDs, we will insert a new pivot // record, otherwise, we will just update this existing record on this joining // table, so that the developers will easily update these records pain free. if ( ! in_array ( $ id , $ current ) ) { $ this -> attach ( $ id , $ attributes , $ touch ) ; $ changes [ 'attached' ] [ ] = is_numeric ( $ id ) ? ( int ) $ id : ( string ) $ id ; } // Now we'll try to update an existing pivot record with the attributes that were // given to the method. If the model is actually updated we will add it to the // list of updated pivot records so we return them back out to the consumer. elseif ( count ( $ attributes ) > 0 && $ this -> updateExistingPivot ( $ id , $ attributes , $ touch ) ) { $ changes [ 'updated' ] [ ] = is_numeric ( $ id ) ? ( int ) $ id : ( string ) $ id ; } } return $ changes ; }
docstring: Attach all of the IDs that aren't in the current array.
  
  @param  array  $records
  @param  array  $current
  @param  bool   $touch
  @return array
docstring_tokens: Attach all of the IDs that aren t in the current array .