File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff 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
@@ -238,7 +245,7 @@ public function readRow( array $row, array $mapping )
238245 public function insert ( array $ seedData )
239246 {
240247 try {
241- DB ::table ($ this ->table )->insert ($ seedData );
248+ DB ::table ($ this ->table )->insert ($ this -> should_trim ? trim ( $ seedData ) : $ seedData );
242249 } catch (\Exception $ e ) {
243250 Log::error ("CSV insert failed: " . $ e ->getMessage () . " - CSV " . $ this ->filename );
244251 return FALSE ;
You can’t perform that action at this time.
0 commit comments