Completed
Pull Request — master (#135)
by
unknown
04:40
created
app/Http/Controllers/SiteController.php 2 patches
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.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,10 +65,11 @@
 block discarded – undo
65 65
     {
66 66
         $locations = $site->locations()->orderBy('name', 'ASC')->paginate(15);
67 67
     
68
-        if (\Request::ajax())
69
-            return response()->json(['site' => $site, 'locations' => $locations]);
70
-        else
71
-            return view('site.show', [ 'site' => $site, 'locations' => $locations ]);
68
+        if (\Request::ajax()) {
69
+                    return response()->json(['site' => $site, 'locations' => $locations]);
70
+        } else {
71
+                    return view('site.show', [ 'site' => $site, 'locations' => $locations ]);
72
+        }
72 73
     }
73 74
     
74 75
     /**
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.