Skip to content

Commit d29bc4e

Browse files
authored
Merge pull request #20 from Midwestern-Interactive/master
Allow trimming white space on column
2 parents 9b6b261 + 1cdae4c commit d29bc4e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Flynsarmy/CsvSeeder/CsvSeeder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ class CsvSeeder extends Seeder
6161
*/
6262
public $offset_rows = 0;
6363

64+
/**
65+
* Can be used to tell the import to trim any leading or trailing white space from the column;
66+
*
67+
* @var bool
68+
*/
69+
public $should_trim = false;
70+
6471

6572
/**
6673
* The mapping of CSV to DB column. If not specified manually, the first
@@ -218,7 +225,7 @@ public function readRow( array $row, array $mapping )
218225
$row_values[$dbCol] = NULL;
219226
}
220227
else {
221-
$row_values[$dbCol] = $row[$csvCol];
228+
$row_values[$dbCol] = $this->should_trim ? trim($row[$csvCol]) : $row[$csvCol];
222229
}
223230
}
224231

0 commit comments

Comments
 (0)