@@ -5,7 +5,7 @@ |
||
5 | 5 | use App\SystemCategories; |
6 | 6 | use Faker\Generator as Faker; |
7 | 7 | |
8 | -$factory->define(SystemCategories::class, function (Faker $faker) { |
|
8 | +$factory->define(SystemCategories::class, function(Faker $faker) { |
|
9 | 9 | return [ |
10 | 10 | // |
11 | 11 | 'name' => $faker->text(15) |
@@ -83,8 +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')) { |
|
87 | - Schema::table('users', function (Blueprint $table) { |
|
86 | + if(!Schema::hasColumn('users', 'password_expires')) { |
|
87 | + Schema::table('users', function(Blueprint $table) { |
|
88 | 88 | $table->timestamp('password_expires') |
89 | 89 | ->nullable() |
90 | 90 | ->after('active'); |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | // Add the is installer column to the users table |
96 | 96 | private function addIsInstallerToUsers() |
97 | 97 | { |
98 | - if (!Schema::hasColumn('users', 'is_installer')) { |
|
99 | - Schema::table('users', function (Blueprint $table) { |
|
98 | + if(!Schema::hasColumn('users', 'is_installer')) { |
|
99 | + Schema::table('users', function(Blueprint $table) { |
|
100 | 100 | $table->boolean('is_installer')->default(0)->after('active'); |
101 | 101 | }); |
102 | 102 | |
103 | 103 | // Migrate user roles from the 'user roles' table to the new 'user permissions' table |
104 | - if (Schema::hasTable('user_permissions') && (UserPermissions::all()->isEmpty())) { |
|
104 | + if(Schema::hasTable('user_permissions') && (UserPermissions::all()->isEmpty())) { |
|
105 | 105 | $userRoles = DB::select('SELECT * FROM `user_role` LEFT JOIN `roles` ON `user_role`.`role_id` = `roles`.`role_id`'); |
106 | 106 | |
107 | - foreach ($userRoles as $user) { |
|
108 | - if ($user->name === 'Installer') { |
|
107 | + foreach($userRoles as $user) { |
|
108 | + if($user->name === 'Installer') { |
|
109 | 109 | User::find($user->user_id)->update( |
110 | 110 | [ |
111 | 111 | 'is_installer' => 1 |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | 'modify_category' => 1 |
127 | 127 | ] |
128 | 128 | ); |
129 | - } else if ($user->name === 'Admin') { |
|
129 | + } else if($user->name === 'Admin') { |
|
130 | 130 | UserPermissions::create( |
131 | 131 | [ |
132 | 132 | 'user_id' => $user->user_id, |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | 'modify_category' => 1 |
143 | 143 | ] |
144 | 144 | ); |
145 | - } else if ($user->name === 'Report') { |
|
145 | + } else if($user->name === 'Report') { |
|
146 | 146 | UserPermissions::create( |
147 | 147 | [ |
148 | 148 | 'user_id' => $user->user_id, |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | // Added a 'hidden' attribute to system customer data types to allow passwords to not be viewed unless clicked or focus |
184 | 184 | private function addHiddenColumn() |
185 | 185 | { |
186 | - if (!Schema::hasColumn('system_cust_data_types', 'hidden')) { |
|
187 | - Schema::table('system_cust_data_types', function (Blueprint $table) { |
|
186 | + if(!Schema::hasColumn('system_cust_data_types', 'hidden')) { |
|
187 | + Schema::table('system_cust_data_types', function(Blueprint $table) { |
|
188 | 188 | $table->boolean('hidden') |
189 | 189 | ->default(0) |
190 | 190 | ->after('name'); |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | // Update the File links table - add cust_id and note column |
196 | 196 | private function addColumnsToFileLinksTable() |
197 | 197 | { |
198 | - if (!Schema::hasColumn('file_links', 'cust_id')) { |
|
199 | - Schema::table('file_links', function (Blueprint $table) { |
|
198 | + if(!Schema::hasColumn('file_links', 'cust_id')) { |
|
199 | + Schema::table('file_links', function(Blueprint $table) { |
|
200 | 200 | $table->integer('cust_id') |
201 | 201 | ->unsigned() |
202 | 202 | ->nullable() |
@@ -204,15 +204,15 @@ discard block |
||
204 | 204 | $table->foreign('cust_id')->references('cust_id')->on('customers')->onUpdate('cascade')->onDelete('cascade'); |
205 | 205 | }); |
206 | 206 | } |
207 | - if (!Schema::hasColumn('file_links', 'note')) { |
|
208 | - Schema::table('file_links', function (Blueprint $table) { |
|
207 | + if(!Schema::hasColumn('file_links', 'note')) { |
|
208 | + Schema::table('file_links', function(Blueprint $table) { |
|
209 | 209 | $table->longText('note') |
210 | 210 | ->nullable() |
211 | 211 | ->after('link_name'); |
212 | 212 | }); |
213 | 213 | // Migrate the instructions from the old table to the new column |
214 | 214 | $instructions = DB::select('SELECT * FROM `file_link_instructions`'); |
215 | - foreach ($instructions as $ins) { |
|
215 | + foreach($instructions as $ins) { |
|
216 | 216 | FileLinks::find($ins->link_id)->update([ |
217 | 217 | 'note' => $ins->instruction |
218 | 218 | ]); |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | // Add Notes column to the file links files table |
224 | 224 | private function addNotesColumnToFileLinkFiles() |
225 | 225 | { |
226 | - if (!Schema::hasColumn('file_link_files', 'note')) { |
|
227 | - Schema::table('file_link_files', function (Blueprint $table) { |
|
226 | + if(!Schema::hasColumn('file_link_files', 'note')) { |
|
227 | + Schema::table('file_link_files', function(Blueprint $table) { |
|
228 | 228 | $table->longText('note') |
229 | 229 | ->nullable() |
230 | 230 | ->after('upload'); |
231 | 231 | }); |
232 | 232 | // Migrate the existing notes to the new table |
233 | 233 | $notes = DB::select('SELECT * FROM `file_link_notes`'); |
234 | - foreach ($notes as $note) { |
|
234 | + foreach($notes as $note) { |
|
235 | 235 | FileLinkFiles::where('file_id', $note->file_id)->update([ |
236 | 236 | 'note' => $note->note |
237 | 237 | ]); |
@@ -242,14 +242,14 @@ discard block |
||
242 | 242 | // Add the documentation column to the tech tips table |
243 | 243 | private function addDocumentationColumnToTechTips() |
244 | 244 | { |
245 | - if (!Schema::hasColumn('tech_tips', 'documentation')) { |
|
246 | - Schema::table('tech_tips', function (Blueprint $table) { |
|
245 | + if(!Schema::hasColumn('tech_tips', 'documentation')) { |
|
246 | + Schema::table('tech_tips', function(Blueprint $table) { |
|
247 | 247 | $table->boolean('documentation')->default(0)->nullable()->after('public'); |
248 | 248 | }); |
249 | 249 | |
250 | 250 | // Move all of the system files over to the tech tips table |
251 | 251 | $sysFiles = DB::select('SELECT * FROM `system_files`'); |
252 | - foreach ($sysFiles as $sysFile) { |
|
252 | + foreach($sysFiles as $sysFile) { |
|
253 | 253 | $newTip = TechTips::create([ |
254 | 254 | 'user_id' => $sysFile->user_id, |
255 | 255 | 'public' => 0, |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | // Remove the active column from the customers table |
286 | 286 | private function removeActiveFromCustomers() |
287 | 287 | { |
288 | - if (Schema::hasColumn('customers', 'active')) |
|
288 | + if(Schema::hasColumn('customers', 'active')) |
|
289 | 289 | { |
290 | 290 | // Migrate the existing disabled customers first |
291 | 291 | $deactiveatedCustomers = Customers::where('active', 0); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | Customers::find($cust->cust_id)->delete(); |
296 | 296 | } |
297 | 297 | |
298 | - Schema::table('customers', function (Blueprint $table) { |
|
298 | + Schema::table('customers', function(Blueprint $table) { |
|
299 | 299 | $table->dropColumn('active'); |
300 | 300 | }); |
301 | 301 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | { |
307 | 307 | if(Schema::hasTable('user_role')) |
308 | 308 | { |
309 | - Schema::table('user_role', function (Blueprint $table) { |
|
309 | + Schema::table('user_role', function(Blueprint $table) { |
|
310 | 310 | $table->dropForeign(['user_id']); |
311 | 311 | $table->dropForeign(['role_id']); |
312 | 312 | }); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | if(Schema::hasTable('file_link_instructions')) |
322 | 322 | { |
323 | 323 | // Remove the foreign key to allow for dropping the table |
324 | - Schema::table('file_link_instructions', function (Blueprint $table) { |
|
324 | + Schema::table('file_link_instructions', function(Blueprint $table) { |
|
325 | 325 | $table->dropForeign(['link_id']); |
326 | 326 | }); |
327 | 327 | Schema::dropIfExists('file_link_instructions'); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | { |
334 | 334 | if(Schema::hasTable('file_link_notes')) |
335 | 335 | { |
336 | - Schema::table('file_link_notes', function (Blueprint $table) { |
|
336 | + Schema::table('file_link_notes', function(Blueprint $table) { |
|
337 | 337 | $table->dropForeign(['link_id']); |
338 | 338 | $table->dropForeign(['file_id']); |
339 | 339 | }); |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | // Remove the system files and system file types table |
345 | 345 | private function removeSystemFilesTables() |
346 | 346 | { |
347 | - if (Schema::hasTable('system_files')) { |
|
348 | - Schema::table('system_files', function (Blueprint $table) { |
|
347 | + if(Schema::hasTable('system_files')) { |
|
348 | + Schema::table('system_files', function(Blueprint $table) { |
|
349 | 349 | $table->dropForeign(['sys_id']); |
350 | 350 | $table->dropForeign(['type_id']); |
351 | 351 | $table->dropForeign(['file_id']); |
@@ -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']); |
@@ -37,7 +37,7 @@ |
||
37 | 37 | 'email' => '[email protected]', |
38 | 38 | 'password' => bcrypt('password'), |
39 | 39 | 'active' => 1, |
40 | - 'is_installer' => 1 |
|
40 | + 'is_installer' => 1 |
|
41 | 41 | ]); |
42 | 42 | } |
43 | 43 |
@@ -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(['user_id' => $user->user_id])); |
18 | 17 | }); |
19 | 18 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | // Submit the new customer form |
38 | 38 | public function store(Request $request) |
39 | 39 | { |
40 | - if (!$this->authorize('hasAccess', 'add_customer')) { |
|
40 | + if(!$this->authorize('hasAccess', 'add_customer')) { |
|
41 | 41 | return abort(403); |
42 | 42 | } |
43 | 43 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | Log::debug('Route '.Route::currentRouteName().' visited by User ID-'.Auth::user()->user_id); |
67 | 67 | Log::notice('New Customer ID-'.$request->custID.' created by User ID-'.Auth::user()->user_id); |
68 | 68 | |
69 | - return response()->json(['success' => true ]); |
|
69 | + return response()->json(['success' => true]); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 |
@@ -37,7 +37,8 @@ |
||
37 | 37 | // Submit the new customer form |
38 | 38 | public function store(Request $request) |
39 | 39 | { |
40 | - if (!$this->authorize('hasAccess', 'add_customer')) { |
|
40 | + if (!$this->authorize('hasAccess', 'add_customer')) |
|
41 | + { |
|
41 | 42 | return abort(403); |
42 | 43 | } |
43 | 44 |