@@ -11,93 +11,94 @@ class WhatNowTableSeeder extends Seeder
1111 */
1212 public function run ()
1313 {
14- $ path = dirname (__FILE__ ) . '/whatnow_entities.csv ' ;
14+ $ path = dirname (__FILE__ ) . '/whatnow_entities.csv ' ;
1515
16- $ file = new SplFileObject ($ path );;
17- $ file ->setFlags (SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV );
18-
19- foreach ($ file as $ row ) {
20-
21- DB ::table ('whatnow_entities ' )->insert ([
22- 'id ' => $ row [0 ],
23- 'org_id ' => $ row [1 ],
24- 'event_type ' => $ row [2 ],
25- 'created_at ' => $ row [3 ],
26- 'updated_at ' => $ row [4 ]
27- ]);
28-
29- }
30-
31- $ path = dirname (__FILE__ ) . '/whatnow_entity_translations.csv ' ;
32-
33- $ file = new SplFileObject ($ path );;
34- $ file ->setFlags (SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV );
16+ $ file = new SplFileObject ($ path );
17+ $ file ->setFlags (SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV );
3518
36- foreach ($ file as $ row ) {
19+ foreach ($ file as $ row ) {
20+ if (count ($ row ) >= 5 ) {
21+ DB ::table ('whatnow_entities ' )->insert ([
22+ 'id ' => $ row [0 ],
23+ 'org_id ' => $ row [1 ],
24+ 'event_type ' => $ row [2 ],
25+ 'created_at ' => $ row [3 ],
26+ 'updated_at ' => $ row [4 ]
27+ ]);
28+ }
29+ }
3730
38- DB ::table ('whatnow_entity_translations ' )->insert ([
39- 'id ' => $ row [0 ],
40- 'entity_id ' => $ row [1 ],
41- 'language_code ' => $ row [2 ],
42- 'title ' => $ row [3 ],
43- 'description ' => $ row [4 ],
44- 'web_url ' => $ row [5 ],
45- 'created_at ' => $ row [6 ],
46- 'published_at ' => $ row [7 ]
47- ]);
31+ $ path = dirname (__FILE__ ) . '/whatnow_entity_translations.csv ' ;
4832
49- }
33+ $ file = new SplFileObject ($ path );
34+ $ file ->setFlags (SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV );
5035
51- $ path = dirname (__FILE__ ) . '/whatnow_entity_stages.csv ' ;
36+ foreach ($ file as $ row ) {
37+ if (count ($ row ) >= 8 ) {
38+ DB ::table ('whatnow_entity_translations ' )->insert ([
39+ 'id ' => $ row [0 ],
40+ 'entity_id ' => $ row [1 ],
41+ 'language_code ' => $ row [2 ],
42+ 'title ' => $ row [3 ],
43+ 'description ' => $ row [4 ],
44+ 'web_url ' => $ row [5 ],
45+ 'created_at ' => $ row [6 ],
46+ 'published_at ' => $ row [7 ]
47+ ]);
48+ }
49+ }
5250
53- $ file = new SplFileObject ($ path );;
54- $ file ->setFlags (SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV );
51+ $ path = dirname (__FILE__ ) . '/whatnow_entity_stages.csv ' ;
5552
56- foreach ($ file as $ row ) {
57- DB ::table ('whatnow_entity_stages ' )->insert ([
58- 'id ' => $ row [0 ],
59- 'translation_id ' => $ row [1 ],
60- 'language_code ' => $ row [2 ],
61- 'stage ' => $ row [3 ],
62- ]);
53+ $ file = new SplFileObject ($ path );
54+ $ file ->setFlags (SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV );
6355
64- }
56+ foreach ($ file as $ row ) {
57+ if (count ($ row ) >= 4 ) {
58+ DB ::table ('whatnow_entity_stages ' )->insert ([
59+ 'id ' => $ row [0 ],
60+ 'translation_id ' => $ row [1 ],
61+ 'language_code ' => $ row [2 ],
62+ 'stage ' => $ row [3 ],
63+ ]);
64+ }
65+ }
6566
6667 $ path = dirname (__FILE__ ) . '/regions.csv ' ;
6768
68- $ file = new SplFileObject ($ path );;
69+ $ file = new SplFileObject ($ path );
6970 $ file ->setFlags (SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV );
7071 $ timestamp = \Carbon \Carbon::now ();
7172
7273 foreach ($ file as $ row ) {
73- DB ::table ('regions ' )->insert ([
74- 'id ' => $ row [0 ],
75- 'organisation_id ' => $ row [1 ],
76- 'title ' => $ row [2 ],
77- 'slug ' => $ row [3 ],
78- 'created_at ' => $ timestamp ,
79- 'updated_at ' => $ timestamp ,
80- ]);
81-
74+ if (count ($ row ) >= 4 ) {
75+ DB ::table ('regions ' )->insert ([
76+ 'id ' => $ row [0 ],
77+ 'organisation_id ' => $ row [1 ],
78+ 'title ' => $ row [2 ],
79+ 'slug ' => $ row [3 ],
80+ 'created_at ' => $ timestamp ,
81+ 'updated_at ' => $ timestamp ,
82+ ]);
83+ }
8284 }
8385
8486 $ path = dirname (__FILE__ ) . '/region_translations.csv ' ;
8587
86- $ file = new SplFileObject ($ path );;
88+ $ file = new SplFileObject ($ path );
8789 $ file ->setFlags (SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV );
8890
8991 foreach ($ file as $ row ) {
90- DB ::table ('region_translations ' )->insert ([
91- 'region_id ' => $ row [0 ],
92- 'language_code ' => $ row [1 ],
93- 'title ' => $ row [2 ],
94- 'description ' => $ row [3 ],
95- 'created_at ' => $ timestamp ,
96- 'updated_at ' => $ timestamp ,
97- ]);
98-
92+ if (count ($ row ) >= 4 ) {
93+ DB ::table ('region_translations ' )->insert ([
94+ 'region_id ' => $ row [0 ],
95+ 'language_code ' => $ row [1 ],
96+ 'title ' => $ row [2 ],
97+ 'description ' => $ row [3 ],
98+ 'created_at ' => $ timestamp ,
99+ 'updated_at ' => $ timestamp ,
100+ ]);
101+ }
99102 }
100-
101103 }
102104}
103-
0 commit comments