@@ -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 | } |
@@ -176,7 +176,7 @@ |
||
176 | 176 | * |
177 | 177 | * @param Request $request |
178 | 178 | * @param Device $device |
179 | - * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection |
|
179 | + * @return \Illuminate\Http\JsonResponse |
|
180 | 180 | */ |
181 | 181 | public function updateCommand(Request $request, Device $device) |
182 | 182 | { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | //Get the first device that doesn't have a null location_id |
36 | 36 | $device = Device::publicDashData()->where('location_id', '!=', 'null')->orderBy('id', 'ASC')->first(); |
37 | 37 | } |
38 | - catch(ModelNotFoundException $e) |
|
38 | + catch (ModelNotFoundException $e) |
|
39 | 39 | { |
40 | 40 | //If no device is found then redirect the user to the home page and display a message about registering a device |
41 | 41 | return redirect('home')->with('no_devices', 'To access the dashboard page there must be at least one registered device assigned to a location.'); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $data = $this->dashData($site, $location, $device); |
50 | 50 | |
51 | - return view('dashboard.index', [ 'active_device' => $data[0], 'devices' => $data[1], 'locations' => $data[2], 'sites' => $data[3] ]); |
|
51 | + return view('dashboard.index', [ 'active_device' => $data[ 0 ], 'devices' => $data[ 1 ], 'locations' => $data[ 2 ], 'sites' => $data[ 3 ] ]); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | //Get the first site and if no sites exist throw an error |
93 | 93 | $site = Site::select('id', 'name')->firstOrFail(); |
94 | 94 | } |
95 | - catch(ModelNotFoundException $e) |
|
95 | + catch (ModelNotFoundException $e) |
|
96 | 96 | { |
97 | 97 | //If no device is found then redirect the user to the home page and display a message about registering a device |
98 | 98 | return redirect('home')->with('no_devices', 'To access the dashboard page there must be at least one registered device assigned to a location.'); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $data = $this->dashData($site, $location, $device); |
120 | 120 | |
121 | - return response()->json([ 'active_device' => $data[0], 'devices' => $data[1], 'locations' => $data[2], 'sites' => $data[3] ]); |
|
121 | + return response()->json([ 'active_device' => $data[ 0 ], 'devices' => $data[ 1 ], 'locations' => $data[ 2 ], 'sites' => $data[ 3 ] ]); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | $data = $this->dashData($site, $location, $device); |
140 | 140 | |
141 | - return response()->json([ 'active_device' => $data[0], 'devices' => $data[1], 'locations' => $data[2], 'sites' => $data[3] ]); |
|
141 | + return response()->json([ 'active_device' => $data[ 0 ], 'devices' => $data[ 1 ], 'locations' => $data[ 2 ], 'sites' => $data[ 3 ] ]); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | $data = $this->dashData($site, $location, $device); |
160 | 160 | |
161 | - return response()->json([ 'active_device' => $data[0], 'devices' => $data[1], 'locations' => $data[2], 'sites' => $data[3] ]); |
|
161 | + return response()->json([ 'active_device' => $data[ 0 ], 'devices' => $data[ 1 ], 'locations' => $data[ 2 ], 'sites' => $data[ 3 ] ]); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | //Get all the devices that belong to the given location ordered by name |
181 | 181 | $devices = $location->devices()->publicDashData()->orderBy('name', 'ASC')->get(); |
182 | 182 | |
183 | - $active_device = collect([$device, $location, $site]); |
|
183 | + $active_device = collect([ $device, $location, $site ]); |
|
184 | 184 | |
185 | - return collect([$active_device, $devices, $locations, $sites]); |
|
185 | + return collect([ $active_device, $devices, $locations, $sites ]); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | return response()->json("Device is currently in use.", 403); |
204 | 204 | |
205 | 205 | //1 = open, 2 = close, 3 = lock |
206 | - switch($request->command) |
|
206 | + switch ($request->command) |
|
207 | 207 | { |
208 | 208 | case 1: |
209 | 209 | $device->cover_command = 'open'; |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | |
240 | 240 | //Check if the current time is during the open schedule or not |
241 | 241 | if (($time_now > $open_time) && ($time_now < $close_time)) |
242 | - $command = 'open'; |
|
242 | + $command = 'open'; |
|
243 | 243 | else |
244 | - $command = 'close'; |
|
244 | + $command = 'close'; |
|
245 | 245 | } |
246 | 246 | else |
247 | - $command = 'lock'; |
|
247 | + $command = 'lock'; |
|
248 | 248 | |
249 | 249 | return $command; |
250 | 250 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | /** |
24 | 24 | * Display index page and process dataTable ajax request. |
25 | 25 | * |
26 | - * @param \App\DataTables\UsersDataTable $dataTable |
|
26 | + * @param ActivityLogDataTable $dataTable |
|
27 | 27 | * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
28 | 28 | */ |
29 | 29 | public function index(ActivityLogDataTable $dataTable) |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected static $ignoreChangedAttributes = ['updated_at']; |
|
27 | + protected static $ignoreChangedAttributes = [ 'updated_at' ]; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * The attributes to log in the Activity Log |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected static $ignoreChangedAttributes = ['updated_at']; |
|
27 | + protected static $ignoreChangedAttributes = [ 'updated_at' ]; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * The attributes to log in the Activity Log |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected static $ignoreChangedAttributes = ['updated_at']; |
|
27 | + protected static $ignoreChangedAttributes = [ 'updated_at' ]; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * The attributes to log in the Activity Log |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * Return null if the site does not have any locations |
105 | 105 | * |
106 | 106 | * @param int $site_id |
107 | - * @return Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection |
|
107 | + * @return \Illuminate\Http\JsonResponse |
|
108 | 108 | */ |
109 | 109 | public function locations($site_id) |
110 | 110 | { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * Return 404 error if the device is not found |
122 | 122 | * |
123 | 123 | * @param int $id |
124 | - * @return Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection |
|
124 | + * @return \Illuminate\Http\JsonResponse |
|
125 | 125 | */ |
126 | 126 | public function details($id) |
127 | 127 | { |
@@ -143,6 +143,6 @@ |
||
143 | 143 | public function roleString() |
144 | 144 | { |
145 | 145 | $role_en = array(0 => "Registered", 1 => "User", 2 => "Manager", 3 => "Admin"); |
146 | - return $role_en[ $this->role ] . ' (' . $this->role . ')'; |
|
146 | + return $role_en[ $this->role ].' ('.$this->role.')'; |
|
147 | 147 | } |
148 | 148 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Creates a json response for all the devices. |
19 | 19 | * |
20 | - * @return Response |
|
20 | + * @return \Illuminate\Http\JsonResponse |
|
21 | 21 | */ |
22 | 22 | public function index() |
23 | 23 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * Creates a json response for a specifc device. |
29 | 29 | * |
30 | 30 | * @param Device $device |
31 | - * @return Response |
|
31 | + * @return \Illuminate\Http\JsonResponse |
|
32 | 32 | */ |
33 | 33 | public function show(Device $device) |
34 | 34 | { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * Updates the status of a device. |
40 | 40 | * |
41 | 41 | * @param Request $request |
42 | - * @return Response |
|
42 | + * @return \Illuminate\Http\JsonResponse |
|
43 | 43 | */ |
44 | 44 | public function update(Request $request) |
45 | 45 | { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * Updates the sensors of a device. |
108 | 108 | * |
109 | 109 | * @param Request $request |
110 | - * @return Response |
|
110 | + * @return \Illuminate\Http\JsonResponse |
|
111 | 111 | */ |
112 | 112 | public function sensor(Request $request) |
113 | 113 | { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * Registers a new device. |
171 | 171 | * |
172 | 172 | * @param Request $request |
173 | - * @return Response |
|
173 | + * @return \Illuminate\Http\JsonResponse |
|
174 | 174 | */ |
175 | 175 | public function register(Request $request) |
176 | 176 | { |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * Updates the image for a device. |
229 | 229 | * |
230 | 230 | * @param Request $request |
231 | - * @return Response |
|
231 | + * @return \Illuminate\Http\JsonResponse |
|
232 | 232 | */ |
233 | 233 | public function image(Request $request) { |
234 | 234 | // Validate the request. |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function index() |
23 | 23 | { |
24 | - return response()->json(['data' => 'SmartSettia API - Bad request type.'], 400); |
|
24 | + return response()->json([ 'data' => 'SmartSettia API - Bad request type.' ], 400); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | //event(new Registered(true)); |
91 | 91 | |
92 | 92 | // Return the new device info including the token. |
93 | - return response()->json(['data' => $device->toArray()], 201); |
|
93 | + return response()->json([ 'data' => $device->toArray() ], 201); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | foreach ($sensor_datas as $sensor_data) { |
128 | 128 | $sensor = Sensor::firstOrCreate([ |
129 | 129 | "device_id" => $device->id, |
130 | - "name" => $sensor_data['name'], |
|
131 | - "type" => $sensor_data['type'] |
|
130 | + "name" => $sensor_data[ 'name' ], |
|
131 | + "type" => $sensor_data[ 'type' ] |
|
132 | 132 | ]); |
133 | 133 | |
134 | 134 | SensorData::create([ |
135 | 135 | "sensor_id" => $sensor->id, |
136 | - "value" => $sensor_data['value'] |
|
136 | + "value" => $sensor_data[ 'value' ] |
|
137 | 137 | ]); |
138 | 138 | } |
139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | //event(new Registered(true)); |
144 | 144 | |
145 | 145 | // Return the new device info including the token. |
146 | - return response()->json(['data' => $device->toArray()], 201); |
|
146 | + return response()->json([ 'data' => $device->toArray() ], 201); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | // If challenge string doesnt match then send 401 unauthorized. |
164 | 164 | if ($request->input('challenge') != env('API_CHALLENGE', 'temppass')) { |
165 | - return response()->json(['data' => 'Bad challenge.'], 401); |
|
165 | + return response()->json([ 'data' => 'Bad challenge.' ], 401); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | // If the uuid already exists then just send them the record. |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | 'uuid' => $device->uuid, |
173 | 173 | 'id' => $device->id, |
174 | 174 | 'token' => $device->token, |
175 | - ]], 200); |
|
175 | + ] ], 200); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | // Create the new device. |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | 'uuid' => $device->uuid, |
197 | 197 | 'id' => $device->id, |
198 | 198 | 'token' => $device->token, |
199 | - ]], 201); |
|
199 | + ] ], 201); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | $device = Device::getDeviceByUUID($request->input('uuid')); |
218 | 218 | |
219 | 219 | // Save the image to disk. |
220 | - $path = $request->file('image')->storeAs('deviceimage', $device['id'], 'private'); |
|
220 | + $path = $request->file('image')->storeAs('deviceimage', $device[ 'id' ], 'private'); |
|
221 | 221 | |
222 | 222 | // Update the url for the image. |
223 | 223 | $deviceimage = Deviceimage::updateOrCreate( |
224 | - ['device_id' => $device['id']], |
|
225 | - ['url' => $path] |
|
224 | + [ 'device_id' => $device[ 'id' ] ], |
|
225 | + [ 'url' => $path ] |
|
226 | 226 | ); |
227 | 227 | |
228 | 228 | // Force the updated_at timestamp to update as the url may not change. |
229 | 229 | $deviceimage->touch(); |
230 | 230 | |
231 | 231 | return response()->json([ 'data' => [ |
232 | - 'id' => $deviceimage['id'], |
|
232 | + 'id' => $deviceimage[ 'id' ], |
|
233 | 233 | 'url' => $path, |
234 | - ]], 201); |
|
234 | + ] ], 201); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 |