Completed
Pull Request — master (#134)
by
unknown
05:19
created
app/Http/Controllers/SiteController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
         $locations = $site->locations()->orderBy('name', 'ASC')->paginate(15);
68 68
     
69 69
         if (\Request::ajax()) {
70
-                    return response()->json(['site' => $site, 'locations' => $locations]);
70
+                    return response()->json([ 'site' => $site, 'locations' => $locations ]);
71 71
         } else {
72 72
                     return view('site.show', [ 'site' => $site, 'locations' => $locations ]);
73 73
         }
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
@@ -28,10 +28,11 @@
 block discarded – undo
28 28
     {
29 29
         $this->authorize('show', Deviceimage::class);
30 30
         
31
-        if (Storage::disk('private')->exists('deviceimage/'.$device_id))
32
-            $image = Image::make(Storage::disk('private')->get('deviceimage/'.$device_id));
33
-        else
34
-            $image = Image::make('img/video_not_found.jpg');
31
+        if (Storage::disk('private')->exists('deviceimage/'.$device_id)) {
32
+                    $image = Image::make(Storage::disk('private')->get('deviceimage/'.$device_id));
33
+        } else {
34
+                    $image = Image::make('img/video_not_found.jpg');
35
+        }
35 36
         
36 37
         return $image->response();
37 38
     }
Please login to merge, or discard this patch.
app/Http/Controllers/UserController.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -133,21 +133,24 @@
 block discarded – undo
133 133
             $user->name = $request->input('name');
134 134
             $user->email = $request->input('email');
135 135
             $user->phone = $request->input('phone');
136
-            if ($request->input('password') != '')
137
-                $user->password = bcrypt($request->input('password'));
138
-            if (Auth::user()->can('updateRole', User::class))
139
-                $user->role = $request->input('role');
136
+            if ($request->input('password') != '') {
137
+                            $user->password = bcrypt($request->input('password'));
138
+            }
139
+            if (Auth::user()->can('updateRole', User::class)) {
140
+                            $user->role = $request->input('role');
141
+            }
142
+        } else {
143
+                    $user->preferred_device_id = $request->input('preferred_device_id');
140 144
         }
141
-        else
142
-            $user->preferred_device_id = $request->input('preferred_device_id');
143 145
 
144 146
         $user->save();
145 147
     
146
-        if (\Request::ajax())
147
-            return response()->json([ 'success' => 'Preferred device updated successfully' ]);
148
-        else
149
-            return redirect()->route('user.show', $user->id)
148
+        if (\Request::ajax()) {
149
+                    return response()->json([ 'success' => 'Preferred device updated successfully' ]);
150
+        } else {
151
+                    return redirect()->route('user.show', $user->id)
150 152
                 ->with('success', 'User updated successfully');
153
+        }
151 154
     }
152 155
 
153 156
     /**
Please login to merge, or discard this patch.
app/Http/Controllers/DeviceController.php 1 patch
Braces   +17 added lines, -14 removed lines patch added patch discarded remove patch
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
                 //Create a new site
112 112
                 $site = Site::create([ 'name' => $request->input('new_site_name') ]);
113 113
                 $site_id = $site->id;
114
+            } else {
115
+                            $site_id = $request->input('site_id');
114 116
             }
115
-            else
116
-                $site_id = $request->input('site_id');
117 117
     
118 118
             //Get the location id of the old or newly created location
119 119
             if (!empty($request->input('new_location_name')))
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
                 //Create a new location
122 122
                 $location = Location::create([ 'name' => $request->input('new_location_name'), 'site_id' => $site_id ]);
123 123
                 $location_id = $location->id;
124
+            } else {
125
+                            $location_id = $request->input('location_id');
124 126
             }
125
-            else
126
-                $location_id = $request->input('location_id');
127 127
     
128 128
             //Update the device
129 129
             $device->location_id = $location_id;
@@ -141,29 +141,32 @@  discard block
 block discarded – undo
141 141
         {
142 142
             $this->authorize('updateCommand', Device::class);
143 143
             //If device is currently opening, closing or in an error state don't update command
144
-            if (!$device->isReadyForCommand())
145
-                return response()->json("Device is currently in use.", 503);
144
+            if (!$device->isReadyForCommand()) {
145
+                            return response()->json("Device is currently in use.", 503);
146
+            }
146 147
     
147 148
             $command = $request->input('command');
148 149
             
149 150
             //If command is to unlock the device then check if the device should be open or closed based on the schedule
150 151
             if ($request->command === 'unlock')
151 152
             {
152
-                if ($device->isDuringScheduleOpen())
153
-                    $command = 'open';
154
-                else
155
-                    $command = 'close';
153
+                if ($device->isDuringScheduleOpen()) {
154
+                                    $command = 'open';
155
+                } else {
156
+                                    $command = 'close';
157
+                }
156 158
             }
157 159
             $device->cover_command = $command;
158 160
         }
159 161
         
160 162
         $device->save();
161 163
     
162
-        if (\Request::ajax())
163
-            return response()->json([ 'success' => 'Device updated successfully' ]);
164
-        else
165
-            return redirect()->route('device.show', $device->id)
164
+        if (\Request::ajax()) {
165
+                    return response()->json([ 'success' => 'Device updated successfully' ]);
166
+        } else {
167
+                    return redirect()->route('device.show', $device->id)
166 168
                 ->with('success', 'Device updated successfully');
169
+        }
167 170
     }
168 171
 
169 172
     /**
Please login to merge, or discard this patch.
app/Policies/UserPolicy.php 1 patch
Braces   +15 added lines, -12 removed lines patch added patch discarded remove patch
@@ -51,10 +51,11 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function show(User $user, User $user2)
53 53
     {
54
-        if ($user->isAdmin())
55
-            return true;
56
-        else
57
-            return $user->isUser() && $user->id === $user2->id;
54
+        if ($user->isAdmin()) {
55
+                    return true;
56
+        } else {
57
+                    return $user->isUser() && $user->id === $user2->id;
58
+        }
58 59
     }
59 60
     
60 61
     /**
@@ -66,10 +67,11 @@  discard block
 block discarded – undo
66 67
      */
67 68
     public function edit(User $user, User $user2)
68 69
     {
69
-        if ($user->isAdmin())
70
-            return true;
71
-        else
72
-            return $user->isUser() && $user->id === $user2->id;
70
+        if ($user->isAdmin()) {
71
+                    return true;
72
+        } else {
73
+                    return $user->isUser() && $user->id === $user2->id;
74
+        }
73 75
     }
74 76
 
75 77
     /**
@@ -81,10 +83,11 @@  discard block
 block discarded – undo
81 83
      */
82 84
     public function update(User $user, User $user2)
83 85
     {
84
-        if ($user->isAdmin())
85
-            return true;
86
-        else
87
-            return $user->isUser() && $user->id === $user2->id;
86
+        if ($user->isAdmin()) {
87
+                    return true;
88
+        } else {
89
+                    return $user->isUser() && $user->id === $user2->id;
90
+        }
88 91
     }
89 92
     
90 93
     /**
Please login to merge, or discard this patch.
app/Providers/AuthServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
     {
46 46
         $this->registerPolicies();
47 47
     
48
-        Gate::define('index-dashboard', function ($user) {
48
+        Gate::define('index-dashboard', function($user) {
49 49
             return $user->isUser();
50 50
         });
51 51
     }
Please login to merge, or discard this patch.