@@ -33,7 +33,7 @@ |
||
| 33 | 33 | { |
| 34 | 34 | if ($this->hasIDs()) { |
| 35 | 35 | return [ |
| 36 | - 'ports' => function (Builder $query) { |
|
| 36 | + 'ports' => function(Builder $query) { |
|
| 37 | 37 | $query->whereIn('port_id', $this->getIDs()); |
| 38 | 38 | }, |
| 39 | 39 | ]; |
@@ -52,7 +52,8 @@ discard block |
||
| 52 | 52 | $this->request = $request; |
| 53 | 53 | if (is_null($input)) { |
| 54 | 54 | $this->input = json_decode($request->{'input'}); |
| 55 | - } else { |
|
| 55 | + } |
|
| 56 | + else { |
|
| 56 | 57 | $this->input = $input; |
| 57 | 58 | } |
| 58 | 59 | $this->device = $this->fetchDevice(); |
@@ -72,10 +73,12 @@ discard block |
||
| 72 | 73 | if ($sourceName === 'rrd') { |
| 73 | 74 | if ($format == 'png') { |
| 74 | 75 | $source = $this->createRRDGraph(); |
| 75 | - } else { |
|
| 76 | + } |
|
| 77 | + else { |
|
| 76 | 78 | $source = $this->createRRDXport(); |
| 77 | 79 | } |
| 78 | - } else { |
|
| 80 | + } |
|
| 81 | + else { |
|
| 79 | 82 | throw new UnknownDataSourceException("Source type $source is not supported"); |
| 80 | 83 | } |
| 81 | 84 | |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | if (Auth::user()->hasGlobalRead()) { |
| 28 | 28 | $ports = Port::all(); |
| 29 | - } else { |
|
| 29 | + } |
|
| 30 | + else { |
|
| 30 | 31 | $ports = Auth::user()->ports()->get(); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -64,7 +65,8 @@ discard block |
||
| 64 | 65 | { |
| 65 | 66 | if ($request->user()->hasGlobalRead()) { |
| 66 | 67 | return Port::find($id); |
| 67 | - } else { |
|
| 68 | + } |
|
| 69 | + else { |
|
| 68 | 70 | $user = User::find($request->user()->user_id); |
| 69 | 71 | return $user->ports()->find($id); |
| 70 | 72 | } |
@@ -67,10 +67,12 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | return $this->response->array(array('statusText' => 'OK', 'dashboard_id' => $dashboard->dashboard_id)); |
| 70 | - } else { |
|
| 70 | + } |
|
| 71 | + else { |
|
| 71 | 72 | return $this->response->errorInternal(); |
| 72 | 73 | } |
| 73 | - } else { |
|
| 74 | + } |
|
| 75 | + else { |
|
| 74 | 76 | $errors = $validation->errors(); |
| 75 | 77 | return response()->json($errors, 422); |
| 76 | 78 | } |
@@ -120,10 +122,12 @@ discard block |
||
| 120 | 122 | $dashboard->access = $request->access; |
| 121 | 123 | if ($dashboard->save()) { |
| 122 | 124 | return $this->response->array(array('statusText' => 'OK')); |
| 123 | - } else { |
|
| 125 | + } |
|
| 126 | + else { |
|
| 124 | 127 | return $this->response->errorInternal(); |
| 125 | 128 | } |
| 126 | - } else { |
|
| 129 | + } |
|
| 130 | + else { |
|
| 127 | 131 | $errors = $validation->errors(); |
| 128 | 132 | return response()->json($errors, 422); |
| 129 | 133 | } |
@@ -140,10 +144,12 @@ discard block |
||
| 140 | 144 | if (Dashboard::where('user_id', $request->user()->user_id)->where('dashboard_id', $id)->delete()) { |
| 141 | 145 | if (UsersWidgets::where('dashboard_id', $id)->delete() >= 0) { |
| 142 | 146 | return $this->response->array(array('statusText' => 'OK')); |
| 143 | - } else { |
|
| 147 | + } |
|
| 148 | + else { |
|
| 144 | 149 | return $this->response->errorInternal(); |
| 145 | 150 | } |
| 146 | - } else { |
|
| 151 | + } |
|
| 152 | + else { |
|
| 147 | 153 | return $this->response->errorInternal(); |
| 148 | 154 | } |
| 149 | 155 | } |
@@ -152,7 +158,8 @@ discard block |
||
| 152 | 158 | { |
| 153 | 159 | if (Dashboard::find($id)->widgets()->delete() >= 0) { |
| 154 | 160 | return $this->response->array(array('statusText' => 'OK')); |
| 155 | - } else { |
|
| 161 | + } |
|
| 162 | + else { |
|
| 156 | 163 | return $this->response->errorInternal(); |
| 157 | 164 | } |
| 158 | 165 | } |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | if ($type === 'archive') { |
| 25 | 25 | $notifications = Notification::isArchived($request->user())->get(); |
| 26 | - } else { |
|
| 26 | + } |
|
| 27 | + else { |
|
| 27 | 28 | $notifications = Notification::isUnread()->get(); |
| 28 | 29 | } |
| 29 | 30 | return $this->response->collection($notifications, NotificationTransformer::class); |
@@ -39,13 +40,15 @@ discard block |
||
| 39 | 40 | |
| 40 | 41 | if ($action == 'read') { |
| 41 | 42 | $result = $notification->markRead($enable); |
| 42 | - } elseif ($action == 'sticky') { |
|
| 43 | + } |
|
| 44 | + elseif ($action == 'sticky') { |
|
| 43 | 45 | $result = $notification->markSticky(false); |
| 44 | 46 | } |
| 45 | 47 | |
| 46 | 48 | if ($result === false) { |
| 47 | 49 | return $this->response->errorInternal(); |
| 48 | - } else { |
|
| 50 | + } |
|
| 51 | + else { |
|
| 49 | 52 | return $this->response->array(array('statusText' => 'OK')); |
| 50 | 53 | } |
| 51 | 54 | } |
@@ -64,7 +67,8 @@ discard block |
||
| 64 | 67 | $notification->source = $request->user()->user_id; |
| 65 | 68 | if ($notification->save()) { |
| 66 | 69 | return $this->response->array(array('statusText' => 'OK')); |
| 67 | - } else { |
|
| 70 | + } |
|
| 71 | + else { |
|
| 68 | 72 | return $this->response->errorInternal(); |
| 69 | 73 | } |
| 70 | 74 | } |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | $per_page = $request->per_page ?: 25; |
| 24 | 24 | if ($request->user()->hasGlobalRead()) { |
| 25 | 25 | $devices = Device::paginate($per_page); |
| 26 | - } else { |
|
| 26 | + } |
|
| 27 | + else { |
|
| 27 | 28 | $devices = User::find($request->user()->user_id)->devices()->paginate($per_page); |
| 28 | 29 | } |
| 29 | 30 | return $devices; |
@@ -60,7 +61,8 @@ discard block |
||
| 60 | 61 | { |
| 61 | 62 | if ($request->user()->hasGlobalRead()) { |
| 62 | 63 | $device = Device::find($id); |
| 63 | - } else { |
|
| 64 | + } |
|
| 65 | + else { |
|
| 64 | 66 | $user = User::find($request->user()->user_id); |
| 65 | 67 | $device = $user->devices()->find($id); |
| 66 | 68 | } |
@@ -102,7 +102,7 @@ |
||
| 102 | 102 | public function get($key, $default = null, $is_array = false) |
| 103 | 103 | { |
| 104 | 104 | // return value from cache or fetch it and return it |
| 105 | - return Cache::tags(self::$cache_tag)->remember($key, $this->cache_time, function () use ($key, $default, $is_array) { |
|
| 105 | + return Cache::tags(self::$cache_tag)->remember($key, $this->cache_time, function() use ($key, $default, $is_array) { |
|
| 106 | 106 | // fetch the values from storage |
| 107 | 107 | if (Config::has('config.'.$key)) { |
| 108 | 108 | $config_data = Config::get('config.'.$key, $default); |
@@ -70,16 +70,19 @@ discard block |
||
| 70 | 70 | if (is_string($k) && !str_contains($k, '.') && DbConfig::exactKey($key)->exists() && DbConfig::key($key)->count() == 1) { |
| 71 | 71 | // check that we aren't trying to set an array onto an existing value only setting |
| 72 | 72 | throw new \Exception("Attempting to set array value to existing non-array value at the key '".$key."'"); |
| 73 | - } else { |
|
| 73 | + } |
|
| 74 | + else { |
|
| 74 | 75 | // we are not at the leaf yet, add this chunk to the key and recurse |
| 75 | 76 | $this->set($key.'.'.$k, $v); |
| 76 | 77 | } |
| 77 | - } else { |
|
| 78 | + } |
|
| 79 | + else { |
|
| 78 | 80 | // a leaf, recurse one last time |
| 79 | 81 | $this->set($k, $v); |
| 80 | 82 | } |
| 81 | 83 | } |
| 82 | - } else { |
|
| 84 | + } |
|
| 85 | + else { |
|
| 83 | 86 | // make sure we can save this |
| 84 | 87 | if ($this->isReadOnly($key)) { |
| 85 | 88 | throw new \Exception("The setting '".$key."' is read only"); |
@@ -112,14 +115,16 @@ discard block |
||
| 112 | 115 | if (count($db_data) == 1 && $db_data->first()->config_name == $key && $is_array !== true) { |
| 113 | 116 | // return a value if we are getting one item and it is the requested item (not recursing) |
| 114 | 117 | return $db_data->first()->config_value; |
| 115 | - } elseif (count($db_data) >= 1) { |
|
| 118 | + } |
|
| 119 | + elseif (count($db_data) >= 1) { |
|
| 116 | 120 | // convert the collection to an array |
| 117 | 121 | $result = self::collectionToArray($db_data, $key); |
| 118 | 122 | |
| 119 | 123 | // if we have config_data, merge them |
| 120 | 124 | if (isset($config_data)) { |
| 121 | 125 | return array_replace_recursive($config_data, $result); |
| 122 | - } else { |
|
| 126 | + } |
|
| 127 | + else { |
|
| 123 | 128 | return $result; |
| 124 | 129 | } |
| 125 | 130 | } |
@@ -201,7 +206,8 @@ discard block |
||
| 201 | 206 | $count = DbConfig::key($key)->count(); |
| 202 | 207 | if ($count == 1) { |
| 203 | 208 | $this->flush($key); |
| 204 | - } else { |
|
| 209 | + } |
|
| 210 | + else { |
|
| 205 | 211 | $this->flush(); // possible optimization: selective flush |
| 206 | 212 | } |
| 207 | 213 | |
@@ -235,7 +241,8 @@ discard block |
||
| 235 | 241 | if (is_null($key)) { |
| 236 | 242 | // Clear all cache |
| 237 | 243 | Cache::tags(self::$cache_tag)->flush(); |
| 238 | - } else { |
|
| 244 | + } |
|
| 245 | + else { |
|
| 239 | 246 | // Clear specific path |
| 240 | 247 | $path = []; |
| 241 | 248 | foreach (explode('.', $key) as $element) { |
@@ -260,7 +267,8 @@ discard block |
||
| 260 | 267 | $this->forget($key); |
| 261 | 268 | array_unshift($var, $value); |
| 262 | 269 | $this->set($key, $var); |
| 263 | - } else { |
|
| 270 | + } |
|
| 271 | + else { |
|
| 264 | 272 | $arr = [$value]; |
| 265 | 273 | if (!is_null($var)) { |
| 266 | 274 | $arr[] = $var; |
@@ -284,7 +292,8 @@ discard block |
||
| 284 | 292 | if (is_array($var)) { |
| 285 | 293 | $var[] = $value; |
| 286 | 294 | $this->set($key, $var); |
| 287 | - } else { |
|
| 295 | + } |
|
| 296 | + else { |
|
| 288 | 297 | $arr = array(); |
| 289 | 298 | if (!is_null($var)) { |
| 290 | 299 | $arr[] = $var; |
@@ -79,8 +79,8 @@ |
||
| 79 | 79 | |
| 80 | 80 | $page_setup['navbar'] = [ |
| 81 | 81 | 'Overview' => $device_url, |
| 82 | - 'Graphs' => $device_url . '/graphs', |
|
| 83 | - 'Health' => $device_url . '/health', |
|
| 82 | + 'Graphs' => $device_url.'/graphs', |
|
| 83 | + 'Health' => $device_url.'/health', |
|
| 84 | 84 | ]; |
| 85 | 85 | return view('devices.show', compact(['device', 'page_setup', 'request', 'page'])); |
| 86 | 86 | } |
@@ -20,7 +20,8 @@ |
||
| 20 | 20 | if (Auth::guard($guard)->guest()) { |
| 21 | 21 | if ($request->ajax() || $request->wantsJson()) { |
| 22 | 22 | return response('Unauthorized.', 401); |
| 23 | - } else { |
|
| 23 | + } |
|
| 24 | + else { |
|
| 24 | 25 | return redirect()->guest('login'); |
| 25 | 26 | } |
| 26 | 27 | } |