@@ -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 | }) |
@@ -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 | } |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | /* |
63 | 63 | * Customer Routes |
64 | 64 | */ |
65 | -Route::prefix('customer')->name('customer.')->group(function() |
|
66 | -{ |
|
65 | +Route::prefix('customer')->name('customer.')->group(function() { |
|
67 | 66 | // Customer Files |
68 | 67 | Route::resource('files', 'Customers\CustomerFilesController'); |
69 | 68 | // Custome Notes |
@@ -89,8 +88,7 @@ discard block |
||
89 | 88 | */ |
90 | 89 | Route::resource('tips', 'TechTips\TechTipsController'); |
91 | 90 | Route::post('submit-edit/{id}', 'TechTips\TechTipsController@update') ->name('tips.submit-edit'); |
92 | -Route::prefix('tip')->name('tip.')->group(function() |
|
93 | -{ |
|
91 | +Route::prefix('tip')->name('tip.')->group(function() { |
|
94 | 92 | Route::resource('comments', 'TechTips\TechTipCommentsController'); |
95 | 93 | Route::get('search', 'TechTips\TechTipsController@search') ->name('search'); |
96 | 94 | Route::get('details/{id}/{name}', 'TechTips\TechTipsController@details') ->name('details'); |
@@ -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::where('active', 1)->whereHas('UserSettings', function($query) |
|
252 | - { |
|
255 | + $users = User::where('active', 1)->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'; |
@@ -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 | }); |
@@ -82,7 +82,8 @@ discard block |
||
82 | 82 | // Added the ability to set an expiration date for user passwords - will force them to change after this expires |
83 | 83 | private function addPasswordExpiresColumn() |
84 | 84 | { |
85 | - if(!Schema::hasColumn('users', 'password_expires')) { |
|
85 | + if(!Schema::hasColumn('users', 'password_expires')) |
|
86 | + { |
|
86 | 87 | Schema::table('users', function(Blueprint $table) { |
87 | 88 | $table->timestamp('password_expires') |
88 | 89 | ->nullable() |
@@ -153,7 +154,8 @@ discard block |
||
153 | 154 | // Added a 'hidden' attribute to system customer data types to allow passwords to not be viewed unless clicked or focus |
154 | 155 | private function addHiddenColumn() |
155 | 156 | { |
156 | - if(!Schema::hasColumn('system_data_field_types', 'hidden')) { |
|
157 | + if(!Schema::hasColumn('system_data_field_types', 'hidden')) |
|
158 | + { |
|
157 | 159 | Schema::table('system_cust_data_types', function(Blueprint $table) { |
158 | 160 | $table->boolean('hidden') |
159 | 161 | ->default(0) |
@@ -165,7 +167,8 @@ discard block |
||
165 | 167 | // Update the File links table - add cust_id and note column |
166 | 168 | private function addColumnsToFileLinksTable() |
167 | 169 | { |
168 | - if(!Schema::hasColumn('file_links', 'cust_id')) { |
|
170 | + if(!Schema::hasColumn('file_links', 'cust_id')) |
|
171 | + { |
|
169 | 172 | Schema::table('file_links', function(Blueprint $table) { |
170 | 173 | $table->integer('cust_id') |
171 | 174 | ->unsigned() |
@@ -174,7 +177,8 @@ discard block |
||
174 | 177 | $table->foreign('cust_id')->references('cust_id')->on('customers')->onUpdate('cascade')->onDelete('cascade'); |
175 | 178 | }); |
176 | 179 | } |
177 | - if(!Schema::hasColumn('file_links', 'note')) { |
|
180 | + if(!Schema::hasColumn('file_links', 'note')) |
|
181 | + { |
|
178 | 182 | Schema::table('file_links', function(Blueprint $table) { |
179 | 183 | $table->longText('note') |
180 | 184 | ->nullable() |
@@ -182,7 +186,8 @@ discard block |
||
182 | 186 | }); |
183 | 187 | // Migrate the instructions from the old table to the new column |
184 | 188 | $instructions = DB::select('SELECT * FROM `file_link_instructions`'); |
185 | - foreach($instructions as $ins) { |
|
189 | + foreach($instructions as $ins) |
|
190 | + { |
|
186 | 191 | FileLinks::find($ins->link_id)->update([ |
187 | 192 | 'note' => $ins->instruction |
188 | 193 | ]); |
@@ -193,7 +198,8 @@ discard block |
||
193 | 198 | // Add Notes column to the file links files table |
194 | 199 | private function addNotesColumnToFileLinkFiles() |
195 | 200 | { |
196 | - if(!Schema::hasColumn('file_link_files', 'note')) { |
|
201 | + if(!Schema::hasColumn('file_link_files', 'note')) |
|
202 | + { |
|
197 | 203 | Schema::table('file_link_files', function(Blueprint $table) { |
198 | 204 | $table->longText('note') |
199 | 205 | ->nullable() |
@@ -201,7 +207,8 @@ discard block |
||
201 | 207 | }); |
202 | 208 | // Migrate the existing notes to the new table |
203 | 209 | $notes = DB::select('SELECT * FROM `file_link_notes`'); |
204 | - foreach($notes as $note) { |
|
210 | + foreach($notes as $note) |
|
211 | + { |
|
205 | 212 | FileLinkFiles::where('file_id', $note->file_id)->update([ |
206 | 213 | 'note' => $note->note |
207 | 214 | ]); |
@@ -212,7 +219,8 @@ discard block |
||
212 | 219 | // Add the documentation column to the tech tips table |
213 | 220 | private function migrateSystemDocumentation() |
214 | 221 | { |
215 | - if(!Schema::hasColumn('tech_tips', 'tip_type_id')) { |
|
222 | + if(!Schema::hasColumn('tech_tips', 'tip_type_id')) |
|
223 | + { |
|
216 | 224 | Schema::table('tech_tips', function(Blueprint $table) { |
217 | 225 | $table->bigInteger('tip_type_id')->unsigned()->after('public')->default(1); |
218 | 226 | $table->foreign('tip_type_id')->references('tip_type_id')->on('tech_tip_types')->onUpdate('cascade'); |
@@ -220,7 +228,8 @@ discard block |
||
220 | 228 | |
221 | 229 | // Move all of the system files over to the tech tips table |
222 | 230 | $sysFiles = DB::select('SELECT * FROM `system_files`'); |
223 | - foreach($sysFiles as $sysFile) { |
|
231 | + foreach($sysFiles as $sysFile) |
|
232 | + { |
|
224 | 233 | $newTip = TechTips::create([ |
225 | 234 | 'user_id' => $sysFile->user_id, |
226 | 235 | 'public' => 0, |
@@ -314,7 +323,8 @@ discard block |
||
314 | 323 | // Remove the system files and system file types table |
315 | 324 | private function removeSystemFilesTables() |
316 | 325 | { |
317 | - if(Schema::hasTable('system_files')) { |
|
326 | + if(Schema::hasTable('system_files')) |
|
327 | + { |
|
318 | 328 | Schema::table('system_files', function(Blueprint $table) { |
319 | 329 | $table->dropForeign(['sys_id']); |
320 | 330 | $table->dropForeign(['type_id']); |
@@ -360,7 +370,8 @@ discard block |
||
360 | 370 | // Add soft deletes to tech tips table to prevent accidental deletes |
361 | 371 | private function addSoftDeleteToTechTips() |
362 | 372 | { |
363 | - if (!Schema::hasColumn('tech_tips', 'deleted_at')) { |
|
373 | + if (!Schema::hasColumn('tech_tips', 'deleted_at')) |
|
374 | + { |
|
364 | 375 | Schema::table('tech_tips', function (Blueprint $table) { |
365 | 376 | $table->softDeletes()->after('description'); |
366 | 377 | }); |
@@ -135,7 +135,8 @@ discard block |
||
135 | 135 | // Validate the hash token |
136 | 136 | $user = UserInitialize::where('token', $hash)->get(); |
137 | 137 | |
138 | - if ($user->isEmpty()) { |
|
138 | + if ($user->isEmpty()) |
|
139 | + { |
|
139 | 140 | Log::debug('Route ' . Route::currentRouteName() . ' visited by User ID-' . Auth::user()->user_id); |
140 | 141 | Log::warning('Visitor at IP Address ' . \Request::ip() . ' tried to access invalid initialize hash - ' . $hash); |
141 | 142 | return abort(404); |
@@ -151,7 +152,8 @@ discard block |
||
151 | 152 | { |
152 | 153 | // Verify that the link matches the assigned email address |
153 | 154 | $valid = UserInitialize::where('token', $hash)->first(); |
154 | - if (empty($valid)) { |
|
155 | + if (empty($valid)) |
|
156 | + { |
|
155 | 157 | Log::debug('Route ' . Route::currentRouteName() . ' visited by User ID-' . Auth::user()->user_id); |
156 | 158 | Log::warning('Visitor at IP Address ' . \Request::ip() . ' tried to submit an invalid User Initialization link - ' . $hash); |
157 | 159 | return abort(404); |