@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public function index() |
| 21 | 21 | { |
| 22 | - return response()->json(['data' => 'SmartSettia API - Bad request type.'], 400); |
|
| 22 | + return response()->json([ 'data' => 'SmartSettia API - Bad request type.' ], 400); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | // If validation fails, send the validation error back with status 400. |
| 65 | 65 | if ($validator->fails()) { |
| 66 | - return response()->json(['data' => $validator->errors()], 400); |
|
| 66 | + return response()->json([ 'data' => $validator->errors() ], 400); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // Get the device record. |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // If token doesnt match then send 401 unauthorized. |
| 73 | 73 | if ($request->input('token') != $device->token) { |
| 74 | - return response()->json(['data' => 'Bad token.'], 401); |
|
| 74 | + return response()->json([ 'data' => 'Bad token.' ], 401); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // Update the device. |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | //event(new Registered(true)); |
| 99 | 99 | |
| 100 | 100 | // Return the new device info including the token. |
| 101 | - return response()->json(['data' => $device->toArray()], 201); |
|
| 101 | + return response()->json([ 'data' => $device->toArray() ], 201); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | // If validation fails, send the validation error back with status 400. |
| 119 | 119 | if ($validator->fails()) { |
| 120 | - return response()->json(['data' => $validator->errors()], 400); |
|
| 120 | + return response()->json([ 'data' => $validator->errors() ], 400); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // If challenge string doesnt match then send 401 unauthorized. |
| 124 | 124 | if ($request->input('challenge') != env('API_CHALLENGE', 'temppass')) { |
| 125 | - return response()->json(['data' => 'Bad challenge.'], 401); |
|
| 125 | + return response()->json([ 'data' => 'Bad challenge.' ], 401); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // If the uuid already exists then just send them the record. |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | 'uuid' => $device->uuid, |
| 133 | 133 | 'id' => $device->id, |
| 134 | 134 | 'token' => $device->token, |
| 135 | - ]], 200); |
|
| 135 | + ] ], 200); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Create the new device. |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $device->save(); |
| 143 | 143 | |
| 144 | 144 | //Update the new device's name with its id and the current time |
| 145 | - $device->name = $device->name . "_". $device->id . '_' . date('h:ia-e'); |
|
| 145 | + $device->name = $device->name."_".$device->id.'_'.date('h:ia-e'); |
|
| 146 | 146 | $device->save(); |
| 147 | 147 | |
| 148 | 148 | // Create an api token for the new device. |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | 'uuid' => $device->uuid, |
| 161 | 161 | 'id' => $device->id, |
| 162 | 162 | 'token' => $device->token, |
| 163 | - ]], 201); |
|
| 163 | + ] ], 201); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | // If validation fails, send the validation error back with status 400. |
| 181 | 181 | if ($validator->fails()) { |
| 182 | - return response()->json(['data' => $validator->errors()], 400); |
|
| 182 | + return response()->json([ 'data' => $validator->errors() ], 400); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Get the device record. |
@@ -187,25 +187,25 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // If token doesnt match then send 401 unauthorized. |
| 189 | 189 | if ($request->input('token') != $device->token) { |
| 190 | - return response()->json(['data' => 'Bad token.'], 401); |
|
| 190 | + return response()->json([ 'data' => 'Bad token.' ], 401); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // Save the image to disk. |
| 194 | - $path = $request->file('image')->storeAs('deviceimage', $device['id'], 'private'); |
|
| 194 | + $path = $request->file('image')->storeAs('deviceimage', $device[ 'id' ], 'private'); |
|
| 195 | 195 | |
| 196 | 196 | // Update the url for the image. |
| 197 | 197 | $deviceimage = Deviceimage::updateOrCreate( |
| 198 | - ['device_id' => $device['id']], |
|
| 199 | - ['url' => $path] |
|
| 198 | + [ 'device_id' => $device[ 'id' ] ], |
|
| 199 | + [ 'url' => $path ] |
|
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | 202 | // Force the updated_at timestamp to update as the url may not change. |
| 203 | 203 | $deviceimage->touch(); |
| 204 | 204 | |
| 205 | 205 | return response()->json([ 'data' => [ |
| 206 | - 'id' => $deviceimage['id'], |
|
| 206 | + 'id' => $deviceimage[ 'id' ], |
|
| 207 | 207 | 'url' => $path, |
| 208 | - ]], 201); |
|
| 208 | + ] ], 201); |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |