@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * Creates a json response for all the devices. |
| 16 | 16 | * |
| 17 | - * @return Response |
|
| 17 | + * @return \Illuminate\Http\JsonResponse |
|
| 18 | 18 | */ |
| 19 | 19 | public function index() |
| 20 | 20 | { |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * Creates a json response for a specifc device. |
| 26 | 26 | * |
| 27 | 27 | * @param Device $device |
| 28 | - * @return Response |
|
| 28 | + * @return \Illuminate\Http\JsonResponse |
|
| 29 | 29 | */ |
| 30 | 30 | public function show(Device $device) |
| 31 | 31 | { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * Updates the status of a device. |
| 37 | 37 | * |
| 38 | 38 | * @param Request $request |
| 39 | - * @return Response |
|
| 39 | + * @return \Illuminate\Http\JsonResponse |
|
| 40 | 40 | */ |
| 41 | 41 | public function update(Request $request) |
| 42 | 42 | { |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * Registers a new device. |
| 108 | 108 | * |
| 109 | 109 | * @param Request $request |
| 110 | - * @return Response |
|
| 110 | + * @return \Illuminate\Http\JsonResponse |
|
| 111 | 111 | */ |
| 112 | 112 | public function register(Request $request) |
| 113 | 113 | { |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * Updates the image for a device. |
| 165 | 165 | * |
| 166 | 166 | * @param Request $request |
| 167 | - * @return Response |
|
| 167 | + * @return \Illuminate\Http\JsonResponse |
|
| 168 | 168 | */ |
| 169 | 169 | public function image(Request $request) { |
| 170 | 170 | // Validate the request. |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @param int $location_id |
| 133 | 133 | * @param int $site_id |
| 134 | - * @return Device|Illuminate\Database\Eloquent\Model |
|
| 134 | + * @return integer |
|
| 135 | 135 | */ |
| 136 | 136 | public function getLocationUpdateDevice($location_id, $site_id) |
| 137 | 137 | { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * Get the very first device and its location and site info based on location id and site id |
| 161 | 161 | * |
| 162 | 162 | * @param int $site_id |
| 163 | - * @return Device|Illuminate\Database\Eloquent\Model |
|
| 163 | + * @return integer |
|
| 164 | 164 | */ |
| 165 | 165 | public function getSiteUpdateDevice($site_id) |
| 166 | 166 | { |
@@ -80,8 +80,7 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | $sites = $this->site_m->orderedSitesBy($location->site_id); |
| 82 | 82 | $locations = $this->location_m->orderedSiteLocationsBy($location->site_id, $device->location_id); |
| 83 | - } |
|
| 84 | - else |
|
| 83 | + } else |
|
| 85 | 84 | { |
| 86 | 85 | $locations = null; |
| 87 | 86 | $sites = $this->site_m->all(); |
@@ -178,10 +177,11 @@ discard block |
||
| 178 | 177 | ]); |
| 179 | 178 | |
| 180 | 179 | if ($validator->fails()) { |
| 181 | - if ($request->input('from') == 'modal') |
|
| 182 | - return response()->json(['errors'=>$validator->errors()], 422); |
|
| 183 | - else |
|
| 184 | - return redirect('device/'.$id.'/edit')->withErrors($validator)->withInput(); |
|
| 180 | + if ($request->input('from') == 'modal') { |
|
| 181 | + return response()->json(['errors'=>$validator->errors()], 422); |
|
| 182 | + } else { |
|
| 183 | + return redirect('device/'.$id.'/edit')->withErrors($validator)->withInput(); |
|
| 184 | + } |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $siteNew = !empty($request->input('new_site_name')); |
@@ -191,8 +191,7 @@ discard block |
||
| 191 | 191 | //Create a new site |
| 192 | 192 | $siteName = $request->input('new_site_name'); |
| 193 | 193 | $site_id = $this->site_m->createSite($siteName); |
| 194 | - } |
|
| 195 | - else |
|
| 194 | + } else |
|
| 196 | 195 | { |
| 197 | 196 | $site_id = $request->input('site'); |
| 198 | 197 | } |
@@ -204,8 +203,7 @@ discard block |
||
| 204 | 203 | //Create a new location |
| 205 | 204 | $locationName = $request->input('new_location_name'); |
| 206 | 205 | $location_id = $this->location_m->createLocation($locationName, $site_id); |
| 207 | - } |
|
| 208 | - else |
|
| 206 | + } else |
|
| 209 | 207 | { |
| 210 | 208 | $location_id = $request->input('location'); |
| 211 | 209 | } |
@@ -220,10 +218,11 @@ discard block |
||
| 220 | 218 | //If the old site isn't connected to a device then remove it |
| 221 | 219 | $this->removeUnusedSite($oldLocationID); |
| 222 | 220 | |
| 223 | - if ($request->input('from') == 'modal') |
|
| 224 | - return "Success"; |
|
| 225 | - else |
|
| 226 | - return redirect('device'); |
|
| 221 | + if ($request->input('from') == 'modal') { |
|
| 222 | + return "Success"; |
|
| 223 | + } else { |
|
| 224 | + return redirect('device'); |
|
| 225 | + } |
|
| 227 | 226 | } |
| 228 | 227 | |
| 229 | 228 | /** |
@@ -240,8 +239,7 @@ discard block |
||
| 240 | 239 | { |
| 241 | 240 | //If the user was already deleted then permanently delete it |
| 242 | 241 | $this->device_m->destroy($id); |
| 243 | - } |
|
| 244 | - else |
|
| 242 | + } else |
|
| 245 | 243 | { |
| 246 | 244 | //Remove the location from the device |
| 247 | 245 | $oldLocation_id = $device->location_id; |
@@ -287,8 +285,7 @@ discard block |
||
| 287 | 285 | { |
| 288 | 286 | //Get the site connected to the location and delete it |
| 289 | 287 | $this->site_m->findOrFail($site_id)->delete(); |
| 290 | - } |
|
| 291 | - else |
|
| 288 | + } else |
|
| 292 | 289 | { |
| 293 | 290 | //Delete the location that isn't used anymore |
| 294 | 291 | $oldLocation->delete(); |