| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Pterodactyl - Panel | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Copyright (c) 2015 - 2017 Dane Everitt <[email protected]>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * in the Software without restriction, including without limitation the rights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * furnished to do so, subject to the following conditions: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * The above copyright notice and this permission notice shall be included in all | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * copies or substantial portions of the Software. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * SOFTWARE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | namespace Pterodactyl\Http\Controllers\Admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Log; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Alert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use Storage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use Pterodactyl\Models; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use Illuminate\Http\Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use Pterodactyl\Exceptions\DisplayException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use Pterodactyl\Http\Controllers\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use Pterodactyl\Repositories\ServiceRepository\Pack; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use Pterodactyl\Exceptions\DisplayValidationException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | class PackController extends Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     public function listAll(Request $request) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         return view('admin.services.packs.index', ['services' => Models\Service::all()]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     public function listByOption(Request $request, $id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         return view('admin.services.packs.byoption', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             'option' => Models\ServiceOption::with('service', 'packs')->findOrFail($id), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function listByService(Request $request, $id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         return view('admin.services.packs.byservice', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             'service' => Models\Service::with('options', 'options.packs')->findOrFail($id), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     public function new(Request $request, $opt = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         return view('admin.services.packs.new', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             'services' => Models\Service::with('options')->get(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     public function create(Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             $repo = new Pack; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             $pack = $repo->create($request->only([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 'name', 'version', 'description', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 'option', 'selectable', 'visible', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                 'file_upload', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             Alert::success('Successfully created new service!')->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             return redirect()->route('admin.services.packs.edit', $pack->id)->withInput(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         } catch (DisplayValidationException $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             return redirect()->route('admin.services.packs.new', $request->input('option'))->withErrors(json_decode($ex->getMessage()))->withInput(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         } catch (DisplayException $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |             Alert::danger($ex->getMessage())->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         } catch (\Exception $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             Log::error($ex); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             Alert::danger('An error occured while attempting to add a new service pack.')->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         return redirect()->route('admin.services.packs.new', $request->input('option'))->withInput(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     public function edit(Request $request, $id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $pack = Models\ServicePack::with('option.service')->findOrFail($id); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         return view('admin.services.packs.edit', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             'pack' => $pack, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             'services' => Models\Service::all()->load('options'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             'files' => Storage::files('packs/' . $pack->uuid), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     public function update(Request $request, $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         if (! is_null($request->input('action_delete'))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                 $repo = new Pack; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |                 $repo->delete($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                 Alert::success('The requested service pack has been deleted from the system.')->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                 return redirect()->route('admin.services.packs'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             } catch (DisplayException $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |                 Alert::danger($ex->getMessage())->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             } catch (\Exception $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                 Log::error($ex); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                 Alert::danger('An error occured while attempting to delete this pack.')->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             return redirect()->route('admin.services.packs.edit', $id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 $repo = new Pack; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                 $repo->update($id, $request->only([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                     'name', 'version', 'description', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                     'option', 'selectable', 'visible', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |                 ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |                 Alert::success('Service pack has been successfully updated.')->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             } catch (DisplayValidationException $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                 return redirect()->route('admin.services.packs.edit', $id)->withErrors(json_decode($ex->getMessage()))->withInput(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             } catch (\Exception $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                 Log::error($ex); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                 Alert::danger('An error occured while attempting to add edit this pack.')->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             return redirect()->route('admin.services.packs.edit', $id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     public function export(Request $request, $id, $files = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         $pack = Models\ServicePack::findOrFail($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $json = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             'name' => $pack->name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             'version' => $pack->version, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             'description' => $pack->dscription, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             'selectable' => (bool) $pack->selectable, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             'visible' => (bool) $pack->visible, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         $filename = tempnam(sys_get_temp_dir(), 'pterodactyl_'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         if ((bool) $files) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |             $zip = new \ZipArchive; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |             if (! $zip->open($filename, \ZipArchive::CREATE)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 abort(503, 'Unable to open file for writing.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             $files = Storage::files('packs/' . $pack->uuid); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             foreach ($files as $file) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                 $zip->addFile(storage_path('app/' . $file), basename(storage_path('app/' . $file))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |             $zip->addFromString('import.json', json_encode($json, JSON_PRETTY_PRINT)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             $zip->close(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             return response()->download($filename, 'pack-' . $pack->name . '.zip')->deleteFileAfterSend(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             $fp = fopen($filename, 'a+'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             fwrite($fp, json_encode($json, JSON_PRETTY_PRINT)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             fclose($fp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             return response()->download($filename, 'pack-' . $pack->name . '.json', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                 'Content-Type' => 'application/json', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             ])->deleteFileAfterSend(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  |     public function uploadForm(Request $request, $for = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |         return view('admin.services.packs.upload', [ | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  |             'services' => Models\Service::all()->load('options'), | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  |         ]); | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 186 |  | View Code Duplication |     public function postUpload(Request $request) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             $repo = new Pack; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             $pack = $repo->createWithTemplate($request->only(['option', 'file_upload'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             Alert::success('Successfully created new service!')->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             return redirect()->route('admin.services.packs.edit', $pack->id)->withInput(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         } catch (DisplayValidationException $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             return redirect()->back()->withErrors(json_decode($ex->getMessage()))->withInput(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         } catch (DisplayException $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             Alert::danger($ex->getMessage())->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         } catch (\Exception $ex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             Log::error($ex); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             Alert::danger('An error occured while attempting to add a new service pack.')->flash(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         return redirect()->back(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 205 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 206 |  |  |  | 
            
                        
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.