@@ -83,7 +83,8 @@ discard block |
||
83 | 83 | // Added the ability to set an expiration date for user passwords - will force them to change after this expires |
84 | 84 | private function addPasswordExpiresColumn() |
85 | 85 | { |
86 | - if (!Schema::hasColumn('users', 'password_expires')) { |
|
86 | + if (!Schema::hasColumn('users', 'password_expires')) |
|
87 | + { |
|
87 | 88 | Schema::table('users', function (Blueprint $table) { |
88 | 89 | $table->timestamp('password_expires') |
89 | 90 | ->nullable() |
@@ -95,17 +96,21 @@ discard block |
||
95 | 96 | // Add the is installer column to the users table |
96 | 97 | private function addIsInstallerToUsers() |
97 | 98 | { |
98 | - if (!Schema::hasColumn('users', 'is_installer')) { |
|
99 | + if (!Schema::hasColumn('users', 'is_installer')) |
|
100 | + { |
|
99 | 101 | Schema::table('users', function (Blueprint $table) { |
100 | 102 | $table->boolean('is_installer')->default(0)->after('active'); |
101 | 103 | }); |
102 | 104 | |
103 | 105 | // Migrate user roles from the 'user roles' table to the new 'user permissions' table |
104 | - if (Schema::hasTable('user_permissions') && (UserPermissions::all()->isEmpty())) { |
|
106 | + if (Schema::hasTable('user_permissions') && (UserPermissions::all()->isEmpty())) |
|
107 | + { |
|
105 | 108 | $userRoles = DB::select('SELECT * FROM `user_role` LEFT JOIN `roles` ON `user_role`.`role_id` = `roles`.`role_id`'); |
106 | 109 | |
107 | - foreach ($userRoles as $user) { |
|
108 | - if ($user->name === 'Installer') { |
|
110 | + foreach ($userRoles as $user) |
|
111 | + { |
|
112 | + if ($user->name === 'Installer') |
|
113 | + { |
|
109 | 114 | User::find($user->user_id)->update( |
110 | 115 | [ |
111 | 116 | 'is_installer' => 1 |
@@ -126,7 +131,9 @@ discard block |
||
126 | 131 | 'modify_category' => 1 |
127 | 132 | ] |
128 | 133 | ); |
129 | - } else if ($user->name === 'Admin') { |
|
134 | + } |
|
135 | + else if ($user->name === 'Admin') |
|
136 | + { |
|
130 | 137 | UserPermissions::create( |
131 | 138 | [ |
132 | 139 | 'user_id' => $user->user_id, |
@@ -142,7 +149,9 @@ discard block |
||
142 | 149 | 'modify_category' => 1 |
143 | 150 | ] |
144 | 151 | ); |
145 | - } else if ($user->name === 'Report') { |
|
152 | + } |
|
153 | + else if ($user->name === 'Report') |
|
154 | + { |
|
146 | 155 | UserPermissions::create( |
147 | 156 | [ |
148 | 157 | 'user_id' => $user->user_id, |
@@ -158,7 +167,9 @@ discard block |
||
158 | 167 | 'modify_category' => 0 |
159 | 168 | ] |
160 | 169 | ); |
161 | - } else { |
|
170 | + } |
|
171 | + else |
|
172 | + { |
|
162 | 173 | UserPermissions::create( |
163 | 174 | [ |
164 | 175 | 'user_id' => $user->user_id, |
@@ -183,7 +194,8 @@ discard block |
||
183 | 194 | // Added a 'hidden' attribute to system customer data types to allow passwords to not be viewed unless clicked or focus |
184 | 195 | private function addHiddenColumn() |
185 | 196 | { |
186 | - if (!Schema::hasColumn('system_cust_data_types', 'hidden')) { |
|
197 | + if (!Schema::hasColumn('system_cust_data_types', 'hidden')) |
|
198 | + { |
|
187 | 199 | Schema::table('system_cust_data_types', function (Blueprint $table) { |
188 | 200 | $table->boolean('hidden') |
189 | 201 | ->default(0) |
@@ -195,7 +207,8 @@ discard block |
||
195 | 207 | // Update the File links table - add cust_id and note column |
196 | 208 | private function addColumnsToFileLinksTable() |
197 | 209 | { |
198 | - if (!Schema::hasColumn('file_links', 'cust_id')) { |
|
210 | + if (!Schema::hasColumn('file_links', 'cust_id')) |
|
211 | + { |
|
199 | 212 | Schema::table('file_links', function (Blueprint $table) { |
200 | 213 | $table->integer('cust_id') |
201 | 214 | ->unsigned() |
@@ -204,7 +217,8 @@ discard block |
||
204 | 217 | $table->foreign('cust_id')->references('cust_id')->on('customers')->onUpdate('cascade')->onDelete('cascade'); |
205 | 218 | }); |
206 | 219 | } |
207 | - if (!Schema::hasColumn('file_links', 'note')) { |
|
220 | + if (!Schema::hasColumn('file_links', 'note')) |
|
221 | + { |
|
208 | 222 | Schema::table('file_links', function (Blueprint $table) { |
209 | 223 | $table->longText('note') |
210 | 224 | ->nullable() |
@@ -212,7 +226,8 @@ discard block |
||
212 | 226 | }); |
213 | 227 | // Migrate the instructions from the old table to the new column |
214 | 228 | $instructions = DB::select('SELECT * FROM `file_link_instructions`'); |
215 | - foreach ($instructions as $ins) { |
|
229 | + foreach ($instructions as $ins) |
|
230 | + { |
|
216 | 231 | FileLinks::find($ins->link_id)->update([ |
217 | 232 | 'note' => $ins->instruction |
218 | 233 | ]); |
@@ -223,7 +238,8 @@ discard block |
||
223 | 238 | // Add Notes column to the file links files table |
224 | 239 | private function addNotesColumnToFileLinkFiles() |
225 | 240 | { |
226 | - if (!Schema::hasColumn('file_link_files', 'note')) { |
|
241 | + if (!Schema::hasColumn('file_link_files', 'note')) |
|
242 | + { |
|
227 | 243 | Schema::table('file_link_files', function (Blueprint $table) { |
228 | 244 | $table->longText('note') |
229 | 245 | ->nullable() |
@@ -231,7 +247,8 @@ discard block |
||
231 | 247 | }); |
232 | 248 | // Migrate the existing notes to the new table |
233 | 249 | $notes = DB::select('SELECT * FROM `file_link_notes`'); |
234 | - foreach ($notes as $note) { |
|
250 | + foreach ($notes as $note) |
|
251 | + { |
|
235 | 252 | FileLinkFiles::where('file_id', $note->file_id)->update([ |
236 | 253 | 'note' => $note->note |
237 | 254 | ]); |
@@ -242,14 +259,16 @@ discard block |
||
242 | 259 | // Add the documentation column to the tech tips table |
243 | 260 | private function addDocumentationColumnToTechTips() |
244 | 261 | { |
245 | - if (!Schema::hasColumn('tech_tips', 'documentation')) { |
|
262 | + if (!Schema::hasColumn('tech_tips', 'documentation')) |
|
263 | + { |
|
246 | 264 | Schema::table('tech_tips', function (Blueprint $table) { |
247 | 265 | $table->boolean('documentation')->default(0)->nullable()->after('public'); |
248 | 266 | }); |
249 | 267 | |
250 | 268 | // Move all of the system files over to the tech tips table |
251 | 269 | $sysFiles = DB::select('SELECT * FROM `system_files`'); |
252 | - foreach ($sysFiles as $sysFile) { |
|
270 | + foreach ($sysFiles as $sysFile) |
|
271 | + { |
|
253 | 272 | $newTip = TechTips::create([ |
254 | 273 | 'user_id' => $sysFile->user_id, |
255 | 274 | 'public' => 0, |
@@ -344,7 +363,8 @@ discard block |
||
344 | 363 | // Remove the system files and system file types table |
345 | 364 | private function removeSystemFilesTables() |
346 | 365 | { |
347 | - if (Schema::hasTable('system_files')) { |
|
366 | + if (Schema::hasTable('system_files')) |
|
367 | + { |
|
348 | 368 | Schema::table('system_files', function (Blueprint $table) { |
349 | 369 | $table->dropForeign(['sys_id']); |
350 | 370 | $table->dropForeign(['type_id']); |
@@ -12,8 +12,7 @@ |
||
12 | 12 | public function run() |
13 | 13 | { |
14 | 14 | // Create the test users - note, none are installers - permissions are assigned randomly |
15 | - factory(App\User::class, 15)->create()->each(function($user) |
|
16 | - { |
|
15 | + factory(App\User::class, 15)->create()->each(function($user) { |
|
17 | 16 | $user->UserPermissions()->save(factory(App\UserPermissions::class)->create()); |
18 | 17 | }); |
19 | 18 | } |