@@ -89,10 +89,11 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function getUpdatedAtHumanAttribute() |
91 | 91 | { |
92 | - if ($this->updated_at->diffInDays() > 0) |
|
93 | - return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
94 | - else |
|
95 | - return $this->updated_at->diffForHumans(); |
|
92 | + if ($this->updated_at->diffInDays() > 0) { |
|
93 | + return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
94 | + } else { |
|
95 | + return $this->updated_at->diffForHumans(); |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | /** |
@@ -107,9 +108,10 @@ discard block |
||
107 | 108 | */ |
108 | 109 | public function getCreatedAtHumanAttribute() |
109 | 110 | { |
110 | - if ($this->created_at->diffInDays() > 0) |
|
111 | - return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
112 | - else |
|
113 | - return $this->created_at->diffForHumans(); |
|
111 | + if ($this->created_at->diffInDays() > 0) { |
|
112 | + return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
113 | + } else { |
|
114 | + return $this->created_at->diffForHumans(); |
|
115 | + } |
|
114 | 116 | } |
115 | 117 | } |
@@ -145,10 +145,11 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function getUpdatedAtHumanAttribute() |
147 | 147 | { |
148 | - if ($this->updated_at->diffInDays() > 0) |
|
149 | - return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
150 | - else |
|
151 | - return $this->updated_at->diffForHumans(); |
|
148 | + if ($this->updated_at->diffInDays() > 0) { |
|
149 | + return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
150 | + } else { |
|
151 | + return $this->updated_at->diffForHumans(); |
|
152 | + } |
|
152 | 153 | } |
153 | 154 | |
154 | 155 | /** |
@@ -163,9 +164,10 @@ discard block |
||
163 | 164 | */ |
164 | 165 | public function getCreatedAtHumanAttribute() |
165 | 166 | { |
166 | - if ($this->created_at->diffInDays() > 0) |
|
167 | - return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
168 | - else |
|
169 | - return $this->created_at->diffForHumans(); |
|
167 | + if ($this->created_at->diffInDays() > 0) { |
|
168 | + return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
169 | + } else { |
|
170 | + return $this->created_at->diffForHumans(); |
|
171 | + } |
|
170 | 172 | } |
171 | 173 | } |
172 | 174 | \ No newline at end of file |
@@ -67,10 +67,11 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function getUpdatedAtHumanAttribute() |
69 | 69 | { |
70 | - if ($this->updated_at->diffInDays() > 0) |
|
71 | - return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
72 | - else |
|
73 | - return $this->updated_at->diffForHumans(); |
|
70 | + if ($this->updated_at->diffInDays() > 0) { |
|
71 | + return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
72 | + } else { |
|
73 | + return $this->updated_at->diffForHumans(); |
|
74 | + } |
|
74 | 75 | } |
75 | 76 | |
76 | 77 | /** |
@@ -85,9 +86,10 @@ discard block |
||
85 | 86 | */ |
86 | 87 | public function getCreatedAtHumanAttribute() |
87 | 88 | { |
88 | - if ($this->created_at->diffInDays() > 0) |
|
89 | - return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
90 | - else |
|
91 | - return $this->created_at->diffForHumans(); |
|
89 | + if ($this->created_at->diffInDays() > 0) { |
|
90 | + return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
91 | + } else { |
|
92 | + return $this->created_at->diffForHumans(); |
|
93 | + } |
|
92 | 94 | } |
93 | 95 | } |
94 | 96 | \ No newline at end of file |
@@ -77,10 +77,11 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getUpdatedAtHumanAttribute() |
79 | 79 | { |
80 | - if ($this->updated_at->diffInDays() > 0) |
|
81 | - return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
82 | - else |
|
83 | - return $this->updated_at->diffForHumans(); |
|
80 | + if ($this->updated_at->diffInDays() > 0) { |
|
81 | + return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
82 | + } else { |
|
83 | + return $this->updated_at->diffForHumans(); |
|
84 | + } |
|
84 | 85 | } |
85 | 86 | |
86 | 87 | /** |
@@ -95,9 +96,10 @@ discard block |
||
95 | 96 | */ |
96 | 97 | public function getCreatedAtHumanAttribute() |
97 | 98 | { |
98 | - if ($this->created_at->diffInDays() > 0) |
|
99 | - return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
100 | - else |
|
101 | - return $this->created_at->diffForHumans(); |
|
99 | + if ($this->created_at->diffInDays() > 0) { |
|
100 | + return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
101 | + } else { |
|
102 | + return $this->created_at->diffForHumans(); |
|
103 | + } |
|
102 | 104 | } |
103 | 105 | } |
@@ -164,10 +164,11 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function getUpdatedAtHumanAttribute() |
166 | 166 | { |
167 | - if ($this->updated_at->diffInDays() > 0) |
|
168 | - return $this->updated_at->setTimezone($this->timezone)->format('M d, Y h:i a'); |
|
169 | - else |
|
170 | - return $this->updated_at->diffForHumans(); |
|
167 | + if ($this->updated_at->diffInDays() > 0) { |
|
168 | + return $this->updated_at->setTimezone($this->timezone)->format('M d, Y h:i a'); |
|
169 | + } else { |
|
170 | + return $this->updated_at->diffForHumans(); |
|
171 | + } |
|
171 | 172 | } |
172 | 173 | |
173 | 174 | /** |
@@ -182,9 +183,10 @@ discard block |
||
182 | 183 | */ |
183 | 184 | public function getCreatedAtHumanAttribute() |
184 | 185 | { |
185 | - if ($this->created_at->diffInDays() > 0) |
|
186 | - return $this->created_at->setTimezone($this->timezone)->format('M d, Y h:i a'); |
|
187 | - else |
|
188 | - return $this->created_at->diffForHumans(); |
|
186 | + if ($this->created_at->diffInDays() > 0) { |
|
187 | + return $this->created_at->setTimezone($this->timezone)->format('M d, Y h:i a'); |
|
188 | + } else { |
|
189 | + return $this->created_at->diffForHumans(); |
|
190 | + } |
|
189 | 191 | } |
190 | 192 | } |
@@ -103,8 +103,9 @@ discard block |
||
103 | 103 | $time = new Carbon($value, 'UTC'); |
104 | 104 | |
105 | 105 | //If the user is logged in then use there preferred timezone |
106 | - if (Auth::check()) |
|
107 | - $time = $time->setTimezone(Auth::user()->timezone); |
|
106 | + if (Auth::check()) { |
|
107 | + $time = $time->setTimezone(Auth::user()->timezone); |
|
108 | + } |
|
108 | 109 | |
109 | 110 | return $time->format('H:i'); |
110 | 111 | } |
@@ -136,8 +137,9 @@ discard block |
||
136 | 137 | $time = new Carbon($value, 'UTC'); |
137 | 138 | |
138 | 139 | //If the user is logged in then use there preferred timezone |
139 | - if (Auth::check()) |
|
140 | - $time = $time->setTimezone(Auth::user()->timezone); |
|
140 | + if (Auth::check()) { |
|
141 | + $time = $time->setTimezone(Auth::user()->timezone); |
|
142 | + } |
|
141 | 143 | |
142 | 144 | return $time->format('H:i'); |
143 | 145 | } |
@@ -171,9 +173,9 @@ discard block |
||
171 | 173 | { |
172 | 174 | $time = new Carbon($value, Auth::user()->timezone); |
173 | 175 | $time = $time->setTimezone('UTC'); |
176 | + } else { |
|
177 | + $time = new Carbon($value, 'UTC'); |
|
174 | 178 | } |
175 | - else |
|
176 | - $time = new Carbon($value, 'UTC'); |
|
177 | 179 | |
178 | 180 | $this->attributes['open_time'] = $time->format('H:i:s'); |
179 | 181 | } |
@@ -193,9 +195,9 @@ discard block |
||
193 | 195 | { |
194 | 196 | $time = new Carbon($value, Auth::user()->timezone); |
195 | 197 | $time = $time->setTimezone('UTC'); |
198 | + } else { |
|
199 | + $time = new Carbon($value, 'UTC'); |
|
196 | 200 | } |
197 | - else |
|
198 | - $time = new Carbon($value, 'UTC'); |
|
199 | 201 | |
200 | 202 | $this->attributes['close_time'] = $time->format('H:i:s'); |
201 | 203 | } |
@@ -211,10 +213,11 @@ discard block |
||
211 | 213 | */ |
212 | 214 | public function getLastNetworkUpdateAtHumanAttribute() |
213 | 215 | { |
214 | - if ($this->last_network_update_at->diffInDays() > 0) |
|
215 | - return $this->last_network_update_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
216 | - else |
|
217 | - return $this->last_network_update_at->diffForHumans(); |
|
216 | + if ($this->last_network_update_at->diffInDays() > 0) { |
|
217 | + return $this->last_network_update_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
218 | + } else { |
|
219 | + return $this->last_network_update_at->diffForHumans(); |
|
220 | + } |
|
218 | 221 | } |
219 | 222 | |
220 | 223 | /** |
@@ -229,10 +232,11 @@ discard block |
||
229 | 232 | */ |
230 | 233 | public function getUpdatedAtHumanAttribute() |
231 | 234 | { |
232 | - if ($this->updated_at->diffInDays() > 0) |
|
233 | - return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
234 | - else |
|
235 | - return $this->updated_at->diffForHumans(); |
|
235 | + if ($this->updated_at->diffInDays() > 0) { |
|
236 | + return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
237 | + } else { |
|
238 | + return $this->updated_at->diffForHumans(); |
|
239 | + } |
|
236 | 240 | } |
237 | 241 | |
238 | 242 | /** |
@@ -246,10 +250,11 @@ discard block |
||
246 | 250 | */ |
247 | 251 | public function getCreatedAtHumanAttribute() |
248 | 252 | { |
249 | - if ($this->created_at->diffInDays() > 0) |
|
250 | - return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
251 | - else |
|
252 | - return $this->created_at->diffForHumans(); |
|
253 | + if ($this->created_at->diffInDays() > 0) { |
|
254 | + return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
255 | + } else { |
|
256 | + return $this->created_at->diffForHumans(); |
|
257 | + } |
|
253 | 258 | } |
254 | 259 | |
255 | 260 | /** |
@@ -360,10 +365,11 @@ discard block |
||
360 | 365 | $time_now = Carbon::now($timezone); |
361 | 366 | |
362 | 367 | //Check if the current time is during the open schedule or not |
363 | - if ($time_now->gt($open_time) && $time_now->lt($close_time)) |
|
364 | - return true; |
|
365 | - else |
|
366 | - return false; |
|
368 | + if ($time_now->gt($open_time) && $time_now->lt($close_time)) { |
|
369 | + return true; |
|
370 | + } else { |
|
371 | + return false; |
|
372 | + } |
|
367 | 373 | } |
368 | 374 | |
369 | 375 | /** |
@@ -380,20 +386,22 @@ discard block |
||
380 | 386 | switch ($this['cover_command']) |
381 | 387 | { |
382 | 388 | case 'open': |
383 | - if ($isOpen) |
|
384 | - $status = 'open'; |
|
385 | - else if ($isLocked) |
|
386 | - $status = 'unlocking'; |
|
387 | - else |
|
388 | - $status = 'opening'; |
|
389 | + if ($isOpen) { |
|
390 | + $status = 'open'; |
|
391 | + } else if ($isLocked) { |
|
392 | + $status = 'unlocking'; |
|
393 | + } else { |
|
394 | + $status = 'opening'; |
|
395 | + } |
|
389 | 396 | break; |
390 | 397 | case 'close': |
391 | - if ($isClosed) |
|
392 | - $status = 'closed'; |
|
393 | - else if ($isLocked) |
|
394 | - $status = 'unlocking'; |
|
395 | - else |
|
396 | - $status = 'closing'; |
|
398 | + if ($isClosed) { |
|
399 | + $status = 'closed'; |
|
400 | + } else if ($isLocked) { |
|
401 | + $status = 'unlocking'; |
|
402 | + } else { |
|
403 | + $status = 'closing'; |
|
404 | + } |
|
397 | 405 | break; |
398 | 406 | case 'lock': |
399 | 407 | $status = 'locked'; |
@@ -402,8 +410,9 @@ discard block |
||
402 | 410 | $status = 'error'; |
403 | 411 | } |
404 | 412 | |
405 | - if ($this->cover_status === 'error') |
|
406 | - $status = 'error'; |
|
413 | + if ($this->cover_status === 'error') { |
|
414 | + $status = 'error'; |
|
415 | + } |
|
407 | 416 | |
408 | 417 | return $status; |
409 | 418 | } |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | public function dataTable($query) |
18 | 18 | { |
19 | 19 | return datatables($query) |
20 | - ->editColumn('causer_id', function ($activity) { |
|
21 | - return ($activity->causer_id ? '<a href="/' . ($activity->causer_type == "App\User" ? 'user' : 'device') . '/' . $activity->causer_id . '">' . ($activity->causer->name ?? '') . '</a>' : 'App'); |
|
20 | + ->editColumn('causer_id', function($activity) { |
|
21 | + return ($activity->causer_id ? '<a href="/'.($activity->causer_type == "App\User" ? 'user' : 'device').'/'.$activity->causer_id.'">'.($activity->causer->name ?? '').'</a>' : 'App'); |
|
22 | 22 | }) |
23 | - ->editColumn('subject_id', function ($activity) { |
|
24 | - return ($activity->subject_id ? '<a href="/' . ($activity->subject_type == "App\User" ? 'user' : 'device') . '/' . $activity->subject_id . '">' . ($activity->subject->name ?? '') . '</a>' : 'App'); |
|
23 | + ->editColumn('subject_id', function($activity) { |
|
24 | + return ($activity->subject_id ? '<a href="/'.($activity->subject_type == "App\User" ? 'user' : 'device').'/'.$activity->subject_id.'">'.($activity->subject->name ?? '').'</a>' : 'App'); |
|
25 | 25 | }) |
26 | - ->editColumn('properties', function ($activity) { |
|
26 | + ->editColumn('properties', function($activity) { |
|
27 | 27 | return $activity->properties; |
28 | 28 | }) |
29 | - ->editColumn('created_at', function ($activity) { |
|
29 | + ->editColumn('created_at', function($activity) { |
|
30 | 30 | if ($activity->created_at->diffInDays() > 0) |
31 | 31 | return $activity->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
32 | 32 | else |
33 | 33 | return $activity->created_at->diffForHumans(); |
34 | 34 | }) |
35 | - ->rawColumns(['causer_id', 'subject_id', 'properties']); |
|
35 | + ->rawColumns([ 'causer_id', 'subject_id', 'properties' ]); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -108,6 +108,6 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function filename() |
110 | 110 | { |
111 | - return 'activitylog_' . time(); |
|
111 | + return 'activitylog_'.time(); |
|
112 | 112 | } |
113 | 113 | } |
@@ -27,10 +27,11 @@ |
||
27 | 27 | return $activity->properties; |
28 | 28 | }) |
29 | 29 | ->editColumn('created_at', function ($activity) { |
30 | - if ($activity->created_at->diffInDays() > 0) |
|
31 | - return $activity->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
32 | - else |
|
33 | - return $activity->created_at->diffForHumans(); |
|
30 | + if ($activity->created_at->diffInDays() > 0) { |
|
31 | + return $activity->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a'); |
|
32 | + } else { |
|
33 | + return $activity->created_at->diffForHumans(); |
|
34 | + } |
|
34 | 35 | }) |
35 | 36 | ->rawColumns(['causer_id', 'subject_id', 'properties']); |
36 | 37 | } |
@@ -16,19 +16,19 @@ |
||
16 | 16 | public function dataTable($query) |
17 | 17 | { |
18 | 18 | return datatables($query) |
19 | - ->editColumn('name', function ($device) { |
|
20 | - return '<a href="' . route('device.show', $device->id) . '">' . $device->name . '</a>'; |
|
19 | + ->editColumn('name', function($device) { |
|
20 | + return '<a href="'.route('device.show', $device->id).'">'.$device->name.'</a>'; |
|
21 | 21 | }) |
22 | - ->addColumn('location', function ($device) { |
|
22 | + ->addColumn('location', function($device) { |
|
23 | 23 | return ($device->location->name ?? 'null'); |
24 | 24 | }) |
25 | - ->addColumn('site', function ($device) { |
|
25 | + ->addColumn('site', function($device) { |
|
26 | 26 | return ($device->location->site->name ?? 'null'); |
27 | 27 | }) |
28 | - ->addColumn('rates', function ($device) { |
|
29 | - return $device->update_rate . '/' . $device->image_rate .'/' . $device->sensor_rate; |
|
28 | + ->addColumn('rates', function($device) { |
|
29 | + return $device->update_rate.'/'.$device->image_rate.'/'.$device->sensor_rate; |
|
30 | 30 | }) |
31 | - ->editColumn('updated_at', function ($device) { |
|
31 | + ->editColumn('updated_at', function($device) { |
|
32 | 32 | return (is_object($device->updated_at) ? $device->updatedAtHuman : 'null'); |
33 | 33 | }) |
34 | 34 | ->blacklist([ 'location', 'site', 'rates' ]) |
@@ -16,16 +16,16 @@ |
||
16 | 16 | { |
17 | 17 | return datatables($query) |
18 | 18 | ->editColumn('name', function(User $user) { |
19 | - return '<a href="' . route('user.show', $user->id) . '">'. $user->name . '</a>'; |
|
19 | + return '<a href="'.route('user.show', $user->id).'">'.$user->name.'</a>'; |
|
20 | 20 | }) |
21 | 21 | |
22 | 22 | ->editColumn('role', function(User $user) { |
23 | 23 | return $user->roleString(); |
24 | 24 | }) |
25 | - ->editColumn('updated_at', function ($user) { |
|
25 | + ->editColumn('updated_at', function($user) { |
|
26 | 26 | return $user->updatedAtHuman; |
27 | 27 | }) |
28 | - ->editColumn('created_at', function ($user) { |
|
28 | + ->editColumn('created_at', function($user) { |
|
29 | 29 | return $user->createdAtHuman; |
30 | 30 | }) |
31 | 31 | ->addColumn('action', 'user.action') |