You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+14-4
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ This package allows CSV based seeds.
8
8
9
9
### Installation
10
10
11
-
Require this package in your composer.json and run composer update (or run `composer require flynsarmy/csv-seeder:1.*` directly):
11
+
Require this package in your composer.json and run composer update (or run `composer require flynsarmy/csv-seeder:2.*` directly):
12
12
13
-
"flynsarmy/csv-seeder": "1.0.*"
13
+
"flynsarmy/csv-seeder": "2.0.*"
14
14
15
15
16
16
### Usage
@@ -49,13 +49,17 @@ Drop your CSV into */database/seeds/csvs/your_csv.csv* or whatever path you spec
49
49
50
50
### Configuration
51
51
52
-
In addition to setting the database table and CSV filename, two other configuration options are available. They can be set in your class constructor:
52
+
In addition to setting the database table and CSV filename, the following configuration options are available. They can be set in your class constructor:
53
53
54
54
-`insert_chunk_size` (int 500) An SQL insert statement will trigger every `insert_chunk_size` number of rows while reading the CSV
55
55
-`csv_delimiter` (string ,) The CSV field delimiter.
56
-
-`hashable` (string password) Hash the hashable field, useful if you are importing users and need their passwords hashed. Uses `Hash::make()`. Note: This is EXTREMELY SLOW. If you have a lot of rows in your CSV your import will take quite a long time.
56
+
-`hashable` (array [password]) List of fields to be hashed before import, useful if you are importing users and need their passwords hashed. Uses `Hash::make()`. Note: This is EXTREMELY SLOW. If you have a lot of rows in your CSV your import will take quite a long time.
57
57
-`offset_rows` (int 0) How many rows at the start of the CSV to ignore. Warning: If used, you probably want to set a mapping as your header row in the CSV will be skipped.
58
58
-`mapping` (array []) Associative array of csvCol => dbCol. See examples section for details. If not specified, the first row (after offset) of the CSV will be used as the mapping.
59
+
-`should_trim` (bool false) Whether to trim the data in each cell of the CSV during import.
60
+
-`timestamps` (bool false) Whether or not to add *created_at* and *updated_at* columns on import.
61
+
-`created_at` (string current time in ISO 8601 format) Only used if `timestamps` is `true`
62
+
-`updated_at` (string current time in ISO 8601 format) Only used if `timestamps` is `true`
59
63
60
64
61
65
### Examples
@@ -113,6 +117,12 @@ Skipping the CSV header row (Note: A mapping is required if this is done):
113
117
$this->should_trim = true;
114
118
}
115
119
120
+
### Migration Guide
121
+
122
+
#### 2.0
123
+
124
+
-`$seeder->hashable` is now an `array` of columns rather than a single column name. Wrap your old string value in `[]`.
125
+
116
126
### License
117
127
118
128
CsvSeeder is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
0 commit comments