@@ -35,38 +35,113 @@ public function handle(): void
35
35
$ languageFileExists = file_exists ($ languageJson );
36
36
37
37
if ($ countryFileExists ) {
38
+ $ this ->outputComponents ()->info ('Seeding the database with countries data. ' );
39
+
38
40
$ countries = json_decode (file_get_contents ($ countryJson ), true );
41
+
42
+ $ progress = $ this ->getOutput ()->createProgressBar (count ($ countries ));
43
+ $ progress ->setFormat ("%message% \n %current%/%max% [%bar%] %percent:3s%% " );
44
+ $ progress ->setMessage ('Countries ' );
45
+ $ progress ->setEmptyBarCharacter ('░ ' ); // light shade character \u2591
46
+ $ progress ->setProgressCharacter ('' );
47
+ $ progress ->setBarCharacter ('█ ' );
48
+
39
49
foreach ($ countries as $ country ) {
40
50
DB ::table ('countries ' )->insert ($ country );
51
+ $ progress ->advance ();
41
52
}
53
+
54
+ $ progress ->finish ();
55
+ $ progress ->clear ();
42
56
}
43
57
44
58
if ($ cityFileExists ) {
59
+ $ this ->outputComponents ()->info ('Seeding the database with cities data. ' );
60
+
45
61
$ cities = json_decode (file_get_contents ($ cityJson ), true );
62
+
63
+ $ progress = $ this ->getOutput ()->createProgressBar (count ($ cities ));
64
+ $ progress ->setFormat ("%message% \n %current%/%max% [%bar%] %percent:3s%% " );
65
+ $ progress ->setMessage ('Cities ' );
66
+ $ progress ->setEmptyBarCharacter ('░ ' ); // light shade character \u2591
67
+ $ progress ->setProgressCharacter ('' );
68
+ $ progress ->setBarCharacter ('█ ' );
69
+
46
70
foreach ($ cities as $ city ) {
47
71
DB ::table ('cities ' )->insert ($ city );
72
+
73
+ $ progress ->advance ();
48
74
}
75
+
76
+ $ progress ->finish ();
77
+ $ progress ->clear ();
49
78
}
50
79
51
80
if ($ areaFileExists ) {
81
+ $ this ->outputComponents ()->info ('Seeding the database with areas data. ' );
82
+ $ this ->outputComponents ()->warn ('This WILL take a while :( Time for a coffee :) ' );
83
+
52
84
$ areas = json_decode (file_get_contents ($ areaJson ), true );
85
+
86
+ $ progress = $ this ->getOutput ()->createProgressBar (count ($ areas ));
87
+ $ progress ->setFormat ("%message% \n %current%/%max% [%bar%] %percent:3s%% " );
88
+ $ progress ->setMessage ('Areas ' );
89
+ $ progress ->setEmptyBarCharacter ('░ ' ); // light shade character \u2591
90
+ $ progress ->setProgressCharacter ('' );
91
+ $ progress ->setBarCharacter ('█ ' );
92
+
53
93
foreach ($ areas as $ area ) {
54
94
DB ::table ('areas ' )->insert ($ area );
95
+
96
+ $ progress ->advance ();
55
97
}
98
+
99
+ $ progress ->finish ();
100
+ $ progress ->clear ();
56
101
}
57
102
58
103
if ($ currencyFileExists ) {
104
+ $ this ->outputComponents ()->info ('Seeding the database with currencies data. ' );
105
+
59
106
$ currencies = json_decode (file_get_contents ($ currencyJson ), true );
107
+
108
+ $ progress = $ this ->getOutput ()->createProgressBar (count ($ currencies ));
109
+ $ progress ->setFormat ("%message% \n %current%/%max% [%bar%] %percent:3s%% " );
110
+ $ progress ->setMessage ('Currencies ' );
111
+ $ progress ->setEmptyBarCharacter ('░ ' ); // light shade character \u2591
112
+ $ progress ->setProgressCharacter ('' );
113
+ $ progress ->setBarCharacter ('█ ' );
114
+
60
115
foreach ($ currencies as $ currency ) {
61
116
DB ::table ('currencies ' )->insert ($ currency );
117
+
118
+ $ progress ->advance ();
62
119
}
120
+
121
+ $ progress ->finish ();
122
+ $ progress ->clear ();
63
123
}
64
124
65
125
if ($ languageFileExists ) {
126
+ $ this ->outputComponents ()->info ('Seeding the database with languages data. ' );
127
+
66
128
$ languages = json_decode (file_get_contents ($ languageJson ), true );
129
+
130
+ $ progress = $ this ->getOutput ()->createProgressBar (count ($ languages ));
131
+ $ progress ->setFormat ("%message% \n %current%/%max% [%bar%] %percent:3s%% " );
132
+ $ progress ->setMessage ('Languages ' );
133
+ $ progress ->setEmptyBarCharacter ('░ ' ); // light shade character \u2591
134
+ $ progress ->setProgressCharacter ('' );
135
+ $ progress ->setBarCharacter ('█ ' );
136
+
67
137
foreach ($ languages as $ language ) {
68
138
DB ::table ('languages ' )->insert ($ language );
139
+
140
+ $ progress ->advance ();
69
141
}
142
+
143
+ $ progress ->finish ();
144
+ $ progress ->clear ();
70
145
}
71
146
72
147
$ this ->info ('Seeding the database with locations data is completed. ' );
0 commit comments