Completed
Push — master ( c24137...0f7093 )
by Brandon
34s
created
app/Http/Controllers/SiteController.php 2 patches
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,10 +66,11 @@
 block discarded – undo
66 66
         $site = Site::findOrFail($id);
67 67
         $locations = $site->locations()->orderBy('name', 'ASC')->paginate(15);
68 68
     
69
-        if (\Request::ajax())
70
-            return response()->json(['site' => $site, 'locations' => $locations]);
71
-        else
72
-            return view('site.show', [ 'site' => $site, 'locations' => $locations ]);
69
+        if (\Request::ajax()) {
70
+                    return response()->json(['site' => $site, 'locations' => $locations]);
71
+        } else {
72
+                    return view('site.show', [ 'site' => $site, 'locations' => $locations ]);
73
+        }
73 74
     }
74 75
     
75 76
     /**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
         $locations = $site->locations()->orderBy('name', 'ASC')->paginate(15);
67 67
     
68 68
         if (\Request::ajax())
69
-            return response()->json(['site' => $site, 'locations' => $locations]);
69
+            return response()->json([ 'site' => $site, 'locations' => $locations ]);
70 70
         else
71 71
             return view('site.show', [ 'site' => $site, 'locations' => $locations ]);
72 72
     }
Please login to merge, or discard this patch.
app/Http/Controllers/DashboardController.php 1 patch
Braces   +9 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
             $location = $device->location ?? null;
43 43
             
44 44
             //If the location exists then set the pagination page to be where the device is located
45
-            if ($location != null)
46
-                $request->merge([ 'page' => $device->dashPageNum(4) ]);
45
+            if ($location != null) {
46
+                            $request->merge([ 'page' => $device->dashPageNum(4) ]);
47
+            }
47 48
             $site_id = $location->site_id ?? 0;
48 49
             $location_id = $location->id ?? 0;
49 50
             $device_id = $device->id ?? 0;
50
-        }
51
-        else
51
+        } else
52 52
         {
53 53
             //Get the active site, location, and device ids
54 54
             $site_id = $request->site_id ?? 0;
@@ -82,8 +82,9 @@  discard block
 block discarded – undo
82 82
         {
83 83
             //If the original device with the given device id was not found
84 84
             //Then assign the the first device in the device list as the active device
85
-            if ($active_device == null)
86
-                $active_device = $devices[ 0 ];
85
+            if ($active_device == null) {
86
+                            $active_device = $devices[ 0 ];
87
+            }
87 88
         
88 89
             //Add an attribute to each device defining if it is stale
89 90
             $devices->transform(function($item)
@@ -97,9 +98,9 @@  discard block
 block discarded – undo
97 98
                 {
98 99
                     $imageStaleMins = ceil(($item->image_rate * 3) / 60) + 1;
99 100
                     $item[ 'isImageStale' ] = ($item->image_updated_at <= Carbon::now()->subMinute($imageStaleMins)) ? true : false;
101
+                } else {
102
+                                    $item[ 'isImageStale' ] = false;
100 103
                 }
101
-                else
102
-                    $item[ 'isImageStale' ] = false;
103 104
                 
104 105
                 return $item;
105 106
             });
Please login to merge, or discard this patch.
app/DataTables/ActivityLogDataTable.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
     public function dataTable($query)
18 18
     {
19 19
         return datatables($query)
20
-            ->editColumn('causer_id', function ($activity) {
20
+            ->editColumn('causer_id', function($activity) {
21 21
                 if ($activity->causer_id && is_object($activity->causer)) {
22
-                    return '<a href="' . route($this->getRouteFromType($activity->causer_type), $activity->causer_id) . '">' . $activity->causer->name ?? '' . '</a>';
22
+                    return '<a href="'.route($this->getRouteFromType($activity->causer_type), $activity->causer_id).'">'.$activity->causer->name ?? ''.'</a>';
23 23
                 } else {
24 24
                     return '';
25 25
                 }
26 26
             })
27
-            ->editColumn('subject_id', function ($activity) {
27
+            ->editColumn('subject_id', function($activity) {
28 28
                 if ($activity->subject_id && is_object($activity->subject)) {
29
-                    return '<a href="' . route($this->getRouteFromType($activity->subject_type), $activity->subject_id) . '">' . $activity->subject->name ?? '' . '</a>';
29
+                    return '<a href="'.route($this->getRouteFromType($activity->subject_type), $activity->subject_id).'">'.$activity->subject->name ?? ''.'</a>';
30 30
                 } else {
31 31
                     return '';
32 32
                 }
33 33
             })
34
-            ->editColumn('properties', function ($activity) {
34
+            ->editColumn('properties', function($activity) {
35 35
                 return $activity->properties;
36 36
             })
37
-            ->editColumn('created_at', function ($activity) {
37
+            ->editColumn('created_at', function($activity) {
38 38
                 if ($activity->created_at->diffInDays() > 0) {
39 39
                                     return $activity->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
40 40
                 } else {
41 41
                                     return $activity->created_at->diffForHumans();
42 42
                 }
43 43
             })
44
-            ->rawColumns(['causer_id', 'subject_id', 'properties']);
44
+            ->rawColumns([ 'causer_id', 'subject_id', 'properties' ]);
45 45
     }
46 46
     
47 47
     public function getRouteFromType($type) {
Please login to merge, or discard this patch.
app/Http/Controllers/ImageController.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,10 +25,11 @@
 block discarded – undo
25 25
      */
26 26
     public function show($device_id)
27 27
     {
28
-        if (Storage::disk('private')->exists('deviceimage/'.$device_id))
29
-            $image = Image::make(Storage::disk('private')->get('deviceimage/'.$device_id));
30
-        else
31
-            $image = Image::make('img/video_not_found.jpg');
28
+        if (Storage::disk('private')->exists('deviceimage/'.$device_id)) {
29
+                    $image = Image::make(Storage::disk('private')->get('deviceimage/'.$device_id));
30
+        } else {
31
+                    $image = Image::make('img/video_not_found.jpg');
32
+        }
32 33
         
33 34
         return $image->response();
34 35
     }
Please login to merge, or discard this patch.
app/Http/Controllers/UserController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
             'email' => $request->input('email'),
62 62
             'password' => bcrypt($request->input('password')),
63 63
             'phone' => $request->input('phone'),
64
-            'role' => $request->input('role'),]);
64
+            'role' => $request->input('role'), ]);
65 65
 
66 66
         return redirect()->route('user.show', $user->id)
67 67
             ->with('success', 'User created successfully');
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -117,19 +117,21 @@
 block discarded – undo
117 117
             $user->email = $request->input('email');
118 118
             $user->role = $request->input('role');
119 119
             $user->phone = $request->input('phone');
120
-            if ($request->input('password') != '')
121
-                $user->password = bcrypt($request->input('password'));
120
+            if ($request->input('password') != '') {
121
+                            $user->password = bcrypt($request->input('password'));
122
+            }
123
+        } else {
124
+                    $user->preferred_device_id = $request->input('preferred_device_id');
122 125
         }
123
-        else
124
-            $user->preferred_device_id = $request->input('preferred_device_id');
125 126
     
126 127
         $user->save();
127 128
     
128
-        if (\Request::ajax())
129
-            return response()->json([ 'success' => 'Preferred device updated successfully' ]);
130
-        else
131
-            return redirect()->route('user.show', $user->id)
129
+        if (\Request::ajax()) {
130
+                    return response()->json([ 'success' => 'Preferred device updated successfully' ]);
131
+        } else {
132
+                    return redirect()->route('user.show', $user->id)
132 133
                 ->with('success', 'User updated successfully');
134
+        }
133 135
     }
134 136
 
135 137
     /**
Please login to merge, or discard this patch.
app/Http/Controllers/DeviceController.php 1 patch
Braces   +34 added lines, -24 removed lines patch added patch discarded remove patch
@@ -118,53 +118,63 @@
 block discarded – undo
118 118
                 //Create a new location
119 119
                 $location = Location::create([ 'name' => $request->input('new_location_name'), 'site_id' => $site_id ]);
120 120
                 $location_id = $location->id;
121
-            } else
122
-                $location_id = $request->input('location_id');
121
+            } else {
122
+                            $location_id = $request->input('location_id');
123
+            }
123 124
     
124 125
             //Update the device
125 126
             $device->location_id = $location_id;
126 127
         }
127 128
         
128 129
         //Update the device
129
-        if ($request->input('name') != null)
130
-            $device->name = $request->input('name');
131
-        if ($request->input('open_time') != null)
132
-            $device->open_time = $request->input('open_time');
133
-        if ($request->input('close_time') != null)
134
-            $device->close_time = $request->input('close_time');
135
-        if ($request->input('update_rate') != null)
136
-            $device->update_rate = $request->input('update_rate');
137
-        if ($request->input('image_rate') != null)
138
-            $device->image_rate = $request->input('image_rate');
139
-        if ($request->input('sensor_rate') != null)
140
-            $device->sensor_rate = $request->input('sensor_rate');
130
+        if ($request->input('name') != null) {
131
+                    $device->name = $request->input('name');
132
+        }
133
+        if ($request->input('open_time') != null) {
134
+                    $device->open_time = $request->input('open_time');
135
+        }
136
+        if ($request->input('close_time') != null) {
137
+                    $device->close_time = $request->input('close_time');
138
+        }
139
+        if ($request->input('update_rate') != null) {
140
+                    $device->update_rate = $request->input('update_rate');
141
+        }
142
+        if ($request->input('image_rate') != null) {
143
+                    $device->image_rate = $request->input('image_rate');
144
+        }
145
+        if ($request->input('sensor_rate') != null) {
146
+                    $device->sensor_rate = $request->input('sensor_rate');
147
+        }
141 148
         //Check if the cover_command needs to be updated
142 149
         if ($request->input('command') != null)
143 150
         {
144 151
             //If device is currently opening, closing or in an error state don't update command
145
-            if (!$device->isReadyForCommand())
146
-                return response()->json("Device is currently in use.", 403);
152
+            if (!$device->isReadyForCommand()) {
153
+                            return response()->json("Device is currently in use.", 403);
154
+            }
147 155
     
148 156
             $command = $request->input('command');
149 157
             
150 158
             //If command is to unlock the device then check if the device should be open or closed based on the schedule
151 159
             if ($request->command === 'unlock')
152 160
             {
153
-                if ($device->isDuringScheduleOpen())
154
-                    $command = 'open';
155
-                else
156
-                    $command = 'close';
161
+                if ($device->isDuringScheduleOpen()) {
162
+                                    $command = 'open';
163
+                } else {
164
+                                    $command = 'close';
165
+                }
157 166
             }
158 167
             $device->cover_command = $command;
159 168
         }
160 169
         
161 170
         $device->save();
162 171
     
163
-        if (\Request::ajax())
164
-            return response()->json([ 'success' => 'Device updated successfully' ]);
165
-        else
166
-            return redirect()->route('device.show', $device->id)
172
+        if (\Request::ajax()) {
173
+                    return response()->json([ 'success' => 'Device updated successfully' ]);
174
+        } else {
175
+                    return redirect()->route('device.show', $device->id)
167 176
                 ->with('success', 'Device updated successfully');
177
+        }
168 178
     }
169 179
 
170 180
     /**
Please login to merge, or discard this patch.