@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $hidden = ['token']; |
|
| 27 | + protected $hidden = [ 'token' ]; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The attributes that are mass assignable. |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | if (Storage::disk('private')->exists('deviceimage/'.$device_id)) { |
| 31 | 31 | $image = Image::make(Storage::disk('private')->get('deviceimage/'.$device_id)); |
| 32 | 32 | } else { |
| 33 | - $image = Image::make(public_path() . '/img/video_not_found.jpg'); |
|
| 33 | + $image = Image::make(public_path().'/img/video_not_found.jpg'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return $image->response(); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function store($device_id, $binaryData) |
| 47 | 47 | { |
| 48 | - $storagePath = storage_path('app/private/deviceimage/') . $device_id; |
|
| 48 | + $storagePath = storage_path('app/private/deviceimage/').$device_id; |
|
| 49 | 49 | $image = Image::make($binaryData); |
| 50 | 50 | $image->save($storagePath, 75); |
| 51 | 51 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | public function index() |
| 20 | 20 | { |
| 21 | - return response()->json(['data' => 'SmartSettia API - Bad request type.'], 400); |
|
| 21 | + return response()->json([ 'data' => 'SmartSettia API - Bad request type.' ], 400); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | // If validation fails, send the validation error back with status 400. |
| 64 | 64 | if ($validator->fails()) { |
| 65 | - return response()->json(['data' => $validator->errors()], 400); |
|
| 65 | + return response()->json([ 'data' => $validator->errors() ], 400); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Get the device record. |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | // If token doesnt match then send 401 unauthorized. |
| 72 | 72 | if ($request->input('token') != $device->token) { |
| 73 | - return response()->json(['data' => 'Bad token.'], 401); |
|
| 73 | + return response()->json([ 'data' => 'Bad token.' ], 401); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // Update the device. |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | //event(new Registered(true)); |
| 101 | 101 | |
| 102 | 102 | // Return the new device info including the token. |
| 103 | - return response()->json(['data' => $device->toArray()], 201); |
|
| 103 | + return response()->json([ 'data' => $device->toArray() ], 201); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | // If validation fails, send the validation error back with status 400. |
| 121 | 121 | if ($validator->fails()) { |
| 122 | - return response()->json(['data' => $validator->errors()], 400); |
|
| 122 | + return response()->json([ 'data' => $validator->errors() ], 400); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // If challenge string doesnt match then send 401 unauthorized. |
| 126 | 126 | if ($request->input('challenge') != env('API_CHALLENGE', 'temppass')) { |
| 127 | - return response()->json(['data' => 'Bad challenge.'], 401); |
|
| 127 | + return response()->json([ 'data' => 'Bad challenge.' ], 401); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // If the uuid already exists then just send them the record. |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | 'uuid' => $device->uuid, |
| 135 | 135 | 'id' => $device->id, |
| 136 | 136 | 'token' => $device->token, |
| 137 | - ]], 200); |
|
| 137 | + ] ], 200); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Create the new device. |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | 'uuid' => $device->uuid, |
| 158 | 158 | 'id' => $device->id, |
| 159 | 159 | 'token' => $device->token, |
| 160 | - ]], 201); |
|
| 160 | + ] ], 201); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | // If validation fails, send the validation error back with status 400. |
| 178 | 178 | if ($validator->fails()) { |
| 179 | - return response()->json(['data' => $validator->errors()], 400); |
|
| 179 | + return response()->json([ 'data' => $validator->errors() ], 400); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // Get the device record. |
@@ -184,25 +184,25 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | // If token doesnt match then send 401 unauthorized. |
| 186 | 186 | if ($request->input('token') != $device->token) { |
| 187 | - return response()->json(['data' => 'Bad token.'], 401); |
|
| 187 | + return response()->json([ 'data' => 'Bad token.' ], 401); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Save the image to disk. |
| 191 | - $path = $request->file('image')->storeAs('deviceimage', $device['id'], 'private'); |
|
| 191 | + $path = $request->file('image')->storeAs('deviceimage', $device[ 'id' ], 'private'); |
|
| 192 | 192 | |
| 193 | 193 | // Update the url for the image. |
| 194 | 194 | $deviceimage = Deviceimage::updateOrCreate( |
| 195 | - ['device_id' => $device['id']], |
|
| 196 | - ['url' => $path] |
|
| 195 | + [ 'device_id' => $device[ 'id' ] ], |
|
| 196 | + [ 'url' => $path ] |
|
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | 199 | // Force the updated_at timestamp to update as the url may not change. |
| 200 | 200 | $deviceimage->touch(); |
| 201 | 201 | |
| 202 | 202 | return response()->json([ 'data' => [ |
| 203 | - 'id' => $deviceimage['id'], |
|
| 203 | + 'id' => $deviceimage[ 'id' ], |
|
| 204 | 204 | 'url' => $path, |
| 205 | - ]], 201); |
|
| 205 | + ] ], 201); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
@@ -188,7 +188,7 @@ |
||
| 188 | 188 | |
| 189 | 189 | if ($validator->fails()) { |
| 190 | 190 | if ($request->input('from') == 'modal') |
| 191 | - return response()->json(['errors'=>$validator->errors()], 422); |
|
| 191 | + return response()->json([ 'errors'=>$validator->errors() ], 422); |
|
| 192 | 192 | else |
| 193 | 193 | return redirect('device/'.$id.'/edit')->withErrors($validator)->withInput(); |
| 194 | 194 | } |
@@ -82,8 +82,7 @@ discard block |
||
| 82 | 82 | $sites->prepend($location->site); |
| 83 | 83 | //Add the current location to the front of the collection of locations |
| 84 | 84 | $locations->prepend($location); |
| 85 | - } |
|
| 86 | - else |
|
| 85 | + } else |
|
| 87 | 86 | { |
| 88 | 87 | //Set locations to null since there is no site or location attached to the selected device |
| 89 | 88 | $locations = null; |
@@ -146,8 +145,7 @@ discard block |
||
| 146 | 145 | $sites->prepend($location->site); |
| 147 | 146 | //Add the current location to the front of the collection of locations |
| 148 | 147 | $locations->prepend($location); |
| 149 | - } |
|
| 150 | - else |
|
| 148 | + } else |
|
| 151 | 149 | { |
| 152 | 150 | //Set locations to null since there is no site or location attached to the selected device |
| 153 | 151 | $locations = null; |
@@ -187,10 +185,11 @@ discard block |
||
| 187 | 185 | ]); |
| 188 | 186 | |
| 189 | 187 | if ($validator->fails()) { |
| 190 | - if ($request->input('from') == 'modal') |
|
| 191 | - return response()->json(['errors'=>$validator->errors()], 422); |
|
| 192 | - else |
|
| 193 | - return redirect('device/'.$id.'/edit')->withErrors($validator)->withInput(); |
|
| 188 | + if ($request->input('from') == 'modal') { |
|
| 189 | + return response()->json(['errors'=>$validator->errors()], 422); |
|
| 190 | + } else { |
|
| 191 | + return redirect('device/'.$id.'/edit')->withErrors($validator)->withInput(); |
|
| 192 | + } |
|
| 194 | 193 | } |
| 195 | 194 | |
| 196 | 195 | //Get the site id of the old or newly created site |
@@ -199,8 +198,7 @@ discard block |
||
| 199 | 198 | //Create a new site |
| 200 | 199 | $siteName = $request->input('new_site_name'); |
| 201 | 200 | $site_id = Site::createSite($siteName)->id; |
| 202 | - } |
|
| 203 | - else |
|
| 201 | + } else |
|
| 204 | 202 | { |
| 205 | 203 | $site_id = $request->input('site'); |
| 206 | 204 | } |
@@ -211,8 +209,7 @@ discard block |
||
| 211 | 209 | //Create a new location |
| 212 | 210 | $locationName = $request->input('new_location_name'); |
| 213 | 211 | $location_id = Location::createLocation($locationName, $site_id)->id; |
| 214 | - } |
|
| 215 | - else |
|
| 212 | + } else |
|
| 216 | 213 | { |
| 217 | 214 | $location_id = $request->input('location'); |
| 218 | 215 | } |
@@ -230,10 +227,11 @@ discard block |
||
| 230 | 227 | //Remove any unused sites or locations |
| 231 | 228 | $this->RemoveUnusedSiteLoc(); |
| 232 | 229 | |
| 233 | - if ($request->input('from') == 'modal') |
|
| 234 | - return "Success"; |
|
| 235 | - else |
|
| 236 | - return redirect('device'); |
|
| 230 | + if ($request->input('from') == 'modal') { |
|
| 231 | + return "Success"; |
|
| 232 | + } else { |
|
| 233 | + return redirect('device'); |
|
| 234 | + } |
|
| 237 | 235 | } |
| 238 | 236 | |
| 239 | 237 | /** |
@@ -250,8 +248,7 @@ discard block |
||
| 250 | 248 | { |
| 251 | 249 | //If the device was already deleted then permanently delete it |
| 252 | 250 | Device::destroy($id); |
| 253 | - } |
|
| 254 | - else |
|
| 251 | + } else |
|
| 255 | 252 | { |
| 256 | 253 | //Remove the location from the device |
| 257 | 254 | $device->location_id = null; |