code: protected function applyId(& $row, $id, $identifierField)
      {
          $ids = (array) $id;
          $findId = function ($row) use ($ids, $identifierField) {
              foreach ($ids as $id) {
                  // Foton == FOTON
                  $bool = true;
                  $identifierField = $this->flatten($identifierField);
                  foreach ($identifierField as $identifier) {
                      $bool = $bool && (mb_strtolower($id[$identifier]) === mb_strtolower($row[$identifier]));
                  }
                  if ($bool) {
                      return $id['id'];
                  }
              }
              return 0;
          };
  
          $isDeep = $this->isDeep($row);
  
          if ($isDeep) {
              foreach ($row as $i => & $r) {
                  $r['id'] = $findId($r);
              }
          } else {
              $row['id'] = $findId($row);
          }
      }
docs: Apply inner DB id to row
  
  @param $row
  @param $id
  @param $identifierField