@@ -17,7 +17,8 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function handle($request, Closure $next, $guard = null) |
| 19 | 19 | { |
| 20 | - if(Auth::guard($guard)->check()) { |
|
| 20 | + if(Auth::guard($guard)->check()) |
|
| 21 | + { |
|
| 21 | 22 | return redirect('/dashboard'); |
| 22 | 23 | } |
| 23 | 24 | |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | $searchResults = new CustomersCollection( |
| 48 | 48 | Customers::orderBy($request->sortField, $request->sortType) |
| 49 | 49 | // Search the name, dba name, and cust id columns |
| 50 | - ->where(function($query) use ($request) |
|
| 51 | - { |
|
| 50 | + ->where(function($query) use ($request) { |
|
| 52 | 51 | $query->where('name', 'like', '%' . $request->name . '%') |
| 53 | 52 | ->orWhere('cust_id', 'like', '%' . $request->name . '%') |
| 54 | 53 | ->orWhere('dba_name', 'like', '%' . $request->name . '%'); |
@@ -58,10 +57,8 @@ discard block |
||
| 58 | 57 | // Include the customers systems |
| 59 | 58 | ->with('CustomerSystems.SystemTypes') |
| 60 | 59 | // If the system field is present - search for system type |
| 61 | - ->when($request->system, function($query) use ($request) |
|
| 62 | - { |
|
| 63 | - $query->whereHas('CustomerSystems.SystemTypes', function($query) use ($request) |
|
| 64 | - { |
|
| 60 | + ->when($request->system, function($query) use ($request) { |
|
| 61 | + $query->whereHas('CustomerSystems.SystemTypes', function($query) use ($request) { |
|
| 65 | 62 | $query->where('sys_id', $request->system); |
| 66 | 63 | }); |
| 67 | 64 | }) |
@@ -35,8 +35,7 @@ |
||
| 35 | 35 | // Update the users table to include the 'user_role' column |
| 36 | 36 | if(!Schema::hasColumn('users', 'role_id')) |
| 37 | 37 | { |
| 38 | - Schema::table('users', function(Blueprint $table) |
|
| 39 | - { |
|
| 38 | + Schema::table('users', function(Blueprint $table) { |
|
| 40 | 39 | $table->integer('role_id')->unsigned()->after('user_id')->default(4); |
| 41 | 40 | $table->foreign('role_id')->references('role_id')->on('user_role_types')->onUpdate('cascade'); |
| 42 | 41 | }); |
@@ -181,12 +181,18 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | // Good to go - update user password |
| 183 | 183 | $roleArr = []; |
| 184 | - foreach ($roles as $role) { |
|
| 185 | - if ($role->role_id == 1 && Auth::user()->role_id != 1) { |
|
| 184 | + foreach ($roles as $role) |
|
| 185 | + { |
|
| 186 | + if ($role->role_id == 1 && Auth::user()->role_id != 1) |
|
| 187 | + { |
|
| 186 | 188 | continue; |
| 187 | - } else if ($role->role_id == 2 && Auth::user()->role_id > 1) { |
|
| 189 | + } |
|
| 190 | + else if ($role->role_id == 2 && Auth::user()->role_id > 1) |
|
| 191 | + { |
|
| 188 | 192 | continue; |
| 189 | - } else { |
|
| 193 | + } |
|
| 194 | + else |
|
| 195 | + { |
|
| 190 | 196 | // $roleArr[$role->role_id] = $role->name; |
| 191 | 197 | $roleArr[] = [ |
| 192 | 198 | 'value' => $role->role_id, |
@@ -275,17 +281,20 @@ discard block |
||
| 275 | 281 | $user = User::find($request->user_id); |
| 276 | 282 | |
| 277 | 283 | // Verify this is a valid user ID |
| 278 | - if (!$user) { |
|
| 284 | + if (!$user) |
|
| 285 | + { |
|
| 279 | 286 | $success = false; |
| 280 | 287 | $reason = 'Cannot find user with this ID'; |
| 281 | 288 | } |
| 282 | 289 | // Make sure that the user is not trying to deactivate someone with more permissions |
| 283 | - else if ($user->role_id < Auth::user()->role_id) { |
|
| 290 | + else if ($user->role_id < Auth::user()->role_id) |
|
| 291 | + { |
|
| 284 | 292 | $success = false; |
| 285 | 293 | $reason = 'You cannot change password for a user with higher permissions that you. If this user has locked themselves out, have then use the reset link on the login page.'; |
| 286 | 294 | } |
| 287 | 295 | // Good to go - update user password |
| 288 | - else { |
|
| 296 | + else |
|
| 297 | + { |
|
| 289 | 298 | // Update the user data |
| 290 | 299 | $user->update( |
| 291 | 300 | [ |
@@ -51,14 +51,17 @@ discard block |
||
| 51 | 51 | Log::debug('request Data -> ', $request->toArray()); |
| 52 | 52 | |
| 53 | 53 | // See if there are any search paramaters entered |
| 54 | - if (!$request->search['searchText'] && !isset($request->search['articleType']) && !isset($request->search['systemType'])) { |
|
| 54 | + if (!$request->search['searchText'] && !isset($request->search['articleType']) && !isset($request->search['systemType'])) |
|
| 55 | + { |
|
| 55 | 56 | // No search paramaters, send all tech tips |
| 56 | 57 | $tips = new TechTipsCollection( |
| 57 | 58 | TechTips::orderBy('created_at', 'DESC') |
| 58 | 59 | ->with('SystemTypes') |
| 59 | 60 | ->paginate($request->pagination['perPage']) |
| 60 | 61 | ); |
| 61 | - } else { |
|
| 62 | + } |
|
| 63 | + else |
|
| 64 | + { |
|
| 62 | 65 | $article = isset($request->search['articleType']) ? true : false; |
| 63 | 66 | $system = isset($request->search['systemType']) ? true : false; |
| 64 | 67 | // Search paramaters, filter results |
@@ -146,7 +149,8 @@ discard block |
||
| 146 | 149 | $save = $receiver->receive(); |
| 147 | 150 | |
| 148 | 151 | // See if the uploade has finished |
| 149 | - if ($save->isFinished()) { |
|
| 152 | + if ($save->isFinished()) |
|
| 153 | + { |
|
| 150 | 154 | $this->saveFile($save->getFile()); |
| 151 | 155 | |
| 152 | 156 | return 'uploaded successfully'; |
@@ -248,8 +252,7 @@ discard block |
||
| 248 | 252 | if(!$tipData->supressEmail) |
| 249 | 253 | { |
| 250 | 254 | $details = TechTips::find($tipID); |
| 251 | - $users = User::whereHas('UserSettings', function($query) |
|
| 252 | - { |
|
| 255 | + $users = User::whereHas('UserSettings', function($query) { |
|
| 253 | 256 | $query->where('em_tech_tip', 1); |
| 254 | 257 | })->get(); |
| 255 | 258 | |
@@ -263,7 +266,8 @@ discard block |
||
| 263 | 266 | // Details controller - will move to the show controller with just the tech tip id |
| 264 | 267 | public function details($id, $subject) |
| 265 | 268 | { |
| 266 | - if (session()->has('newTipFile')) { |
|
| 269 | + if (session()->has('newTipFile')) |
|
| 270 | + { |
|
| 267 | 271 | session()->forget('newTipFile'); |
| 268 | 272 | } |
| 269 | 273 | |
@@ -293,7 +297,8 @@ discard block |
||
| 293 | 297 | // Add or remove this tip as a favorite of the user |
| 294 | 298 | public function toggleFav($action, $id) |
| 295 | 299 | { |
| 296 | - switch ($action) { |
|
| 300 | + switch ($action) |
|
| 301 | + { |
|
| 297 | 302 | case 'add': |
| 298 | 303 | TechTipFavs::create([ |
| 299 | 304 | 'user_id' => Auth::user()->user_id, |
@@ -321,7 +326,8 @@ discard block |
||
| 321 | 326 | $this->authorize('hasAccess', 'Edit Tech Tip'); |
| 322 | 327 | $tipData = TechTips::where('tip_id', $id)->with('User')->with('SystemTypes')->with('TechTipTypes')->first(); |
| 323 | 328 | |
| 324 | - if (!$tipData) { |
|
| 329 | + if (!$tipData) |
|
| 330 | + { |
|
| 325 | 331 | return view('tips.tipNotFound'); |
| 326 | 332 | } |
| 327 | 333 | |
@@ -353,7 +359,8 @@ discard block |
||
| 353 | 359 | $receiver = new FileReceiver('file', $request, HandlerFactory::classFromRequest($request)); |
| 354 | 360 | |
| 355 | 361 | // Verify if there is a file to be processed or not |
| 356 | - if ($receiver->isUploaded() === false || $request->_completed) { |
|
| 362 | + if ($receiver->isUploaded() === false || $request->_completed) |
|
| 363 | + { |
|
| 357 | 364 | $this->storeUpdatedTip($request, $id); |
| 358 | 365 | Log::debug('Route ' . Route::currentRouteName() . ' visited by User ID-' . Auth::user()->user_id); |
| 359 | 366 | return response()->json(['tip_id' => $id]); |
@@ -363,7 +370,8 @@ discard block |
||
| 363 | 370 | $save = $receiver->receive(); |
| 364 | 371 | |
| 365 | 372 | // See if the uploade has finished |
| 366 | - if ($save->isFinished()) { |
|
| 373 | + if ($save->isFinished()) |
|
| 374 | + { |
|
| 367 | 375 | $this->saveFile($save->getFile(), $id); |
| 368 | 376 | |
| 369 | 377 | return 'uploaded successfully'; |
@@ -77,7 +77,8 @@ |
||
| 77 | 77 | // Delete an existing category - note this will fail if the category has systems assigned to it |
| 78 | 78 | public function destroy($id) |
| 79 | 79 | { |
| 80 | - try { |
|
| 80 | + try |
|
| 81 | + { |
|
| 81 | 82 | SystemCategories::find($id)->delete(); |
| 82 | 83 | return response()->json(['success' => true, 'reason' => 'Category Successfully Deleted']); |
| 83 | 84 | } |
@@ -131,8 +131,7 @@ discard block |
||
| 131 | 131 | public function edit($id) |
| 132 | 132 | { |
| 133 | 133 | $fields = SystemDataFieldTypes::all(); |
| 134 | - $system = SystemTypes::where('sys_id', $id)->with(['SystemDataFields' => function($query) |
|
| 135 | - { |
|
| 134 | + $system = SystemTypes::where('sys_id', $id)->with(['SystemDataFields' => function($query) { |
|
| 136 | 135 | $query->join('system_data_field_types', 'system_data_fields.data_type_id', '=', 'system_data_field_types.data_type_id'); |
| 137 | 136 | }])->withCount('SystemDataFields')->first(); |
| 138 | 137 | |
@@ -212,7 +211,8 @@ discard block |
||
| 212 | 211 | public function destroy($id) |
| 213 | 212 | { |
| 214 | 213 | // |
| 215 | - try { |
|
| 214 | + try |
|
| 215 | + { |
|
| 216 | 216 | SystemTypes::find($id)->delete(); |
| 217 | 217 | return response()->json(['success' => true, 'reason' => 'Equipment Successfully Deleted']); |
| 218 | 218 | } |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | $userLinks = new UserCollection( |
| 38 | 38 | User::withCount([ |
| 39 | 39 | 'FileLinks', |
| 40 | - 'FileLinks as expired_file_links_count' => function($query) |
|
| 41 | - { |
|
| 40 | + 'FileLinks as expired_file_links_count' => function($query) { |
|
| 42 | 41 | $query->where('expire', '<', Carbon::now()); |
| 43 | 42 | } |
| 44 | 43 | ]) |
@@ -88,7 +87,8 @@ discard block |
||
| 88 | 87 | )->update(['value' => $request->passExpire]); |
| 89 | 88 | |
| 90 | 89 | // If the setting is changing from never to xx days, update all users |
| 91 | - if ($request->passExpire == 0) { |
|
| 90 | + if ($request->passExpire == 0) |
|
| 91 | + { |
|
| 92 | 92 | User::whereNotNull('password_expires')->update([ |
| 93 | 93 | 'password_expires' => null |
| 94 | 94 | ]); |
@@ -110,8 +110,7 @@ discard block |
||
| 110 | 110 | public function roleSettings() |
| 111 | 111 | { |
| 112 | 112 | $this->authorize('hasAccess', 'Manage User Roles'); |
| 113 | - $roles = UserRoleType::with(['UserRolePermissions' => function($query) |
|
| 114 | - { |
|
| 113 | + $roles = UserRoleType::with(['UserRolePermissions' => function($query) { |
|
| 115 | 114 | $query->join('user_role_permission_types', 'user_role_permission_types.perm_type_id', '=', 'user_role_permissions.perm_type_id'); |
| 116 | 115 | }])->get(); |
| 117 | 116 | $perms = UserRolePermissionTypes::all(); |
@@ -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() |
@@ -119,7 +120,8 @@ discard block |
||
| 119 | 120 | // Added a 'hidden' attribute to system customer data types to allow passwords to not be viewed unless clicked or focus |
| 120 | 121 | private function addHiddenColumn() |
| 121 | 122 | { |
| 122 | - if(!Schema::hasColumn('system_data_field_types', 'hidden')) { |
|
| 123 | + if(!Schema::hasColumn('system_data_field_types', 'hidden')) |
|
| 124 | + { |
|
| 123 | 125 | Schema::table('system_cust_data_types', function(Blueprint $table) { |
| 124 | 126 | $table->boolean('hidden') |
| 125 | 127 | ->default(0) |
@@ -131,7 +133,8 @@ discard block |
||
| 131 | 133 | // Update the File links table - add cust_id and note column |
| 132 | 134 | private function addColumnsToFileLinksTable() |
| 133 | 135 | { |
| 134 | - if(!Schema::hasColumn('file_links', 'cust_id')) { |
|
| 136 | + if(!Schema::hasColumn('file_links', 'cust_id')) |
|
| 137 | + { |
|
| 135 | 138 | Schema::table('file_links', function(Blueprint $table) { |
| 136 | 139 | $table->integer('cust_id') |
| 137 | 140 | ->unsigned() |
@@ -140,7 +143,8 @@ discard block |
||
| 140 | 143 | $table->foreign('cust_id')->references('cust_id')->on('customers')->onUpdate('cascade')->onDelete('cascade'); |
| 141 | 144 | }); |
| 142 | 145 | } |
| 143 | - if(!Schema::hasColumn('file_links', 'note')) { |
|
| 146 | + if(!Schema::hasColumn('file_links', 'note')) |
|
| 147 | + { |
|
| 144 | 148 | Schema::table('file_links', function(Blueprint $table) { |
| 145 | 149 | $table->longText('note') |
| 146 | 150 | ->nullable() |
@@ -148,7 +152,8 @@ discard block |
||
| 148 | 152 | }); |
| 149 | 153 | // Migrate the instructions from the old table to the new column |
| 150 | 154 | $instructions = DB::select('SELECT * FROM `file_link_instructions`'); |
| 151 | - foreach($instructions as $ins) { |
|
| 155 | + foreach($instructions as $ins) |
|
| 156 | + { |
|
| 152 | 157 | FileLinks::find($ins->link_id)->update([ |
| 153 | 158 | 'note' => $ins->instruction |
| 154 | 159 | ]); |
@@ -159,7 +164,8 @@ discard block |
||
| 159 | 164 | // Add Notes column to the file links files table |
| 160 | 165 | private function addNotesColumnToFileLinkFiles() |
| 161 | 166 | { |
| 162 | - if(!Schema::hasColumn('file_link_files', 'note')) { |
|
| 167 | + if(!Schema::hasColumn('file_link_files', 'note')) |
|
| 168 | + { |
|
| 163 | 169 | Schema::table('file_link_files', function(Blueprint $table) { |
| 164 | 170 | $table->longText('note') |
| 165 | 171 | ->nullable() |
@@ -167,7 +173,8 @@ discard block |
||
| 167 | 173 | }); |
| 168 | 174 | // Migrate the existing notes to the new table |
| 169 | 175 | $notes = DB::select('SELECT * FROM `file_link_notes`'); |
| 170 | - foreach($notes as $note) { |
|
| 176 | + foreach($notes as $note) |
|
| 177 | + { |
|
| 171 | 178 | FileLinkFiles::where('file_id', $note->file_id)->update([ |
| 172 | 179 | 'note' => $note->note |
| 173 | 180 | ]); |
@@ -178,7 +185,8 @@ discard block |
||
| 178 | 185 | // Add the documentation column to the tech tips table |
| 179 | 186 | private function migrateSystemDocumentation() |
| 180 | 187 | { |
| 181 | - if(!Schema::hasColumn('tech_tips', 'tip_type_id')) { |
|
| 188 | + if(!Schema::hasColumn('tech_tips', 'tip_type_id')) |
|
| 189 | + { |
|
| 182 | 190 | Schema::table('tech_tips', function(Blueprint $table) { |
| 183 | 191 | $table->bigInteger('tip_type_id')->unsigned()->after('public')->default(1); |
| 184 | 192 | $table->foreign('tip_type_id')->references('tip_type_id')->on('tech_tip_types')->onUpdate('cascade'); |
@@ -186,7 +194,8 @@ discard block |
||
| 186 | 194 | |
| 187 | 195 | // Move all of the system files over to the tech tips table |
| 188 | 196 | $sysFiles = DB::select('SELECT * FROM `system_files`'); |
| 189 | - foreach($sysFiles as $sysFile) { |
|
| 197 | + foreach($sysFiles as $sysFile) |
|
| 198 | + { |
|
| 190 | 199 | $newTip = TechTips::create([ |
| 191 | 200 | 'user_id' => $sysFile->user_id, |
| 192 | 201 | 'public' => 0, |
@@ -280,7 +289,8 @@ discard block |
||
| 280 | 289 | // Remove the system files and system file types table |
| 281 | 290 | private function removeSystemFilesTables() |
| 282 | 291 | { |
| 283 | - if(Schema::hasTable('system_files')) { |
|
| 292 | + if(Schema::hasTable('system_files')) |
|
| 293 | + { |
|
| 284 | 294 | Schema::table('system_files', function(Blueprint $table) { |
| 285 | 295 | $table->dropForeign(['sys_id']); |
| 286 | 296 | $table->dropForeign(['type_id']); |
@@ -326,7 +336,8 @@ discard block |
||
| 326 | 336 | // Add soft deletes to tech tips table to prevent accidental deletes |
| 327 | 337 | private function addSoftDeleteToTechTips() |
| 328 | 338 | { |
| 329 | - if (!Schema::hasColumn('tech_tips', 'deleted_at')) { |
|
| 339 | + if (!Schema::hasColumn('tech_tips', 'deleted_at')) |
|
| 340 | + { |
|
| 330 | 341 | Schema::table('tech_tips', function (Blueprint $table) { |
| 331 | 342 | $table->softDeletes()->after('description'); |
| 332 | 343 | }); |
@@ -338,8 +349,7 @@ discard block |
||
| 338 | 349 | { |
| 339 | 350 | if(!Schema::hasColumn('users', 'deleted_at')) |
| 340 | 351 | { |
| 341 | - Schema::table('users', function(Blueprint $table) |
|
| 342 | - { |
|
| 352 | + Schema::table('users', function(Blueprint $table) { |
|
| 343 | 353 | $table->softDeletes()->after('password_expires'); |
| 344 | 354 | }); |
| 345 | 355 | // Migrate over all deactivated users |
@@ -356,34 +366,31 @@ discard block |
||
| 356 | 366 | { |
| 357 | 367 | if(!Schema::hasColumn('customers', 'parent_id')) |
| 358 | 368 | { |
| 359 | - Schema::table('customers', function(Blueprint $table) |
|
| 360 | - { |
|
| 369 | + Schema::table('customers', function(Blueprint $table) { |
|
| 361 | 370 | $table->integer('parent_id')->after('cust_id')->nullable()->unsigned(); |
| 362 | 371 | $table->foreign('parent_id')->references('cust_id')->on('customers')->onUpdate('cascade'); |
| 363 | 372 | }); |
| 364 | 373 | } |
| 365 | 374 | if(!Schema::hasColumn('customer_systems', 'shared')) |
| 366 | 375 | { |
| 367 | - Schema::table('customer_systems', function (Blueprint $table) |
|
| 368 | - { |
|
| 376 | + Schema::table('customer_systems', function (Blueprint $table) { |
|
| 369 | 377 | $table->boolean('shared')->default(0)->after('sys_id'); |
| 370 | 378 | }); |
| 371 | 379 | } |
| 372 | 380 | if (!Schema::hasColumn('customer_contacts', 'shared')) |
| 373 | 381 | { |
| 374 | - Schema::table('customer_contacts', function (Blueprint $table) |
|
| 375 | - { |
|
| 382 | + Schema::table('customer_contacts', function (Blueprint $table) { |
|
| 376 | 383 | $table->boolean('shared')->default(0)->after('cust_id'); |
| 377 | 384 | }); |
| 378 | 385 | } |
| 379 | 386 | if (!Schema::hasColumn('customer_notes', 'shared')) |
| 380 | 387 | { |
| 381 | - Schema::table('customer_notes', function (Blueprint $table) |
|
| 382 | - { |
|
| 388 | + Schema::table('customer_notes', function (Blueprint $table) { |
|
| 383 | 389 | $table->boolean('shared')->default(0)->after('user_id'); |
| 384 | 390 | }); |
| 385 | 391 | } |
| 386 | - if (!Schema::hasColumn('customer_files', 'shared')) { |
|
| 392 | + if (!Schema::hasColumn('customer_files', 'shared')) |
|
| 393 | + { |
|
| 387 | 394 | Schema::table('customer_files', function (Blueprint $table) { |
| 388 | 395 | $table->boolean('shared')->default(0)->after('user_id'); |
| 389 | 396 | }); |