Completed
Pull Request — master (#56)
by
unknown
02:34
created
app/Http/Controllers/HomeController.php 1 patch
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
-use Illuminate\Http\Request;
6
-
7 5
 class HomeController extends Controller
8 6
 {
9 7
     /**
Please login to merge, or discard this patch.
app/Notifications/InvoicePaid.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Illuminate\Bus\Queueable;
6 6
 use Illuminate\Notifications\Notification;
7
-use Illuminate\Contracts\Queue\ShouldQueue;
8 7
 use Illuminate\Notifications\Messages\NexmoMessage;
9 8
 
10 9
 class InvoicePaid extends Notification
Please login to merge, or discard this patch.
app/Device.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      *
25 25
      * @var array
26 26
      */
27
-    protected $hidden = ['token'];
27
+    protected $hidden = [ 'token' ];
28 28
     
29 29
     /**
30 30
      * The attributes that are mass assignable.
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      *
132 132
      * @param int $location_id
133 133
      * @param int $site_id
134
-     * @return Device|Illuminate\Database\Eloquent\Model
134
+     * @return integer
135 135
      */
136 136
     public function getLocationUpdateDevice($location_id, $site_id)
137 137
     {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * Get the very first device and its location and site info based on location id and site id
161 161
      *
162 162
      * @param int $site_id
163
-     * @return Device|Illuminate\Database\Eloquent\Model
163
+     * @return integer
164 164
      */
165 165
     public function getSiteUpdateDevice($site_id)
166 166
     {
Please login to merge, or discard this patch.
app/Http/Controllers/ImageController.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,9 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
-use Illuminate\Http\Request;
6 5
 use Intervention\Image\Facades\Image as Image;
7
-use Illuminate\Support\Facades\Cache;
8 6
 use Illuminate\Support\Facades\Storage;
9 7
 
10 8
 class ImageController extends Controller
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
app/Http/Controllers/ApiController.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * Creates a json response for all the devices.
16 16
      *
17
-     * @return Response
17
+     * @return \Illuminate\Http\JsonResponse
18 18
      */    
19 19
     public function index()
20 20
     {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * Creates a json response for a specifc device.
26 26
      *
27 27
      * @param  Device  $device
28
-     * @return Response
28
+     * @return \Illuminate\Http\JsonResponse
29 29
      */    
30 30
     public function show(Device $device)
31 31
     {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * Updates the status of a device.
37 37
      *
38 38
      * @param  Request  $request
39
-     * @return Response
39
+     * @return \Illuminate\Http\JsonResponse
40 40
      */
41 41
     public function update(Request $request)
42 42
     {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      * Registers a new device.
108 108
      *
109 109
      * @param  Request  $request
110
-     * @return Response
110
+     * @return \Illuminate\Http\JsonResponse
111 111
      */
112 112
     public function register(Request $request)
113 113
     {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * Updates the image for a device.
165 165
      *
166 166
      * @param  Request  $request
167
-     * @return Response
167
+     * @return \Illuminate\Http\JsonResponse
168 168
      */
169 169
     public function image(Request $request) {
170 170
         // Validate the request.
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,6 @@
 block discarded – undo
7 7
 use App\Device;
8 8
 use App\Deviceimage;
9 9
 use App\User;
10
-use Illuminate\Support\Facades\Cache;
11
-use Illuminate\Support\Facades\Storage;
12 10
 
13 11
 class ApiController extends Controller
14 12
 {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      */    
20 20
     public function index()
21 21
     {
22
-        return response()->json(['data' => 'SmartSettia API - Bad request type.'], 400);
22
+        return response()->json([ 'data' => 'SmartSettia API - Bad request type.' ], 400);
23 23
     }
24 24
 
25 25
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         
64 64
         // If validation fails, send the validation error back with status 400.
65 65
         if ($validator->fails()) {
66
-            return response()->json(['data' => $validator->errors()], 400);
66
+            return response()->json([ 'data' => $validator->errors() ], 400);
67 67
         }
68 68
         
69 69
         // Get the device record.
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         
72 72
         // If token doesnt match then send 401 unauthorized.
73 73
         if ($request->input('token') != $device->token) {
74
-            return response()->json(['data' => 'Bad token.'], 401);
74
+            return response()->json([ 'data' => 'Bad token.' ], 401);
75 75
         }
76 76
         
77 77
         // Update the device.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         //event(new Registered(true));
99 99
         
100 100
         // Return the new device info including the token.
101
-        return response()->json(['data' => $device->toArray()], 201);
101
+        return response()->json([ 'data' => $device->toArray() ], 201);
102 102
     }
103 103
     
104 104
     /**
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
         
118 118
         // If validation fails, send the validation error back with status 400.
119 119
         if ($validator->fails()) {
120
-            return response()->json(['data' => $validator->errors()], 400);
120
+            return response()->json([ 'data' => $validator->errors() ], 400);
121 121
         }
122 122
         
123 123
         // If challenge string doesnt match then send 401 unauthorized.
124 124
         if ($request->input('challenge') != env('API_CHALLENGE', 'temppass')) {
125
-            return response()->json(['data' => 'Bad challenge.'], 401);
125
+            return response()->json([ 'data' => 'Bad challenge.' ], 401);
126 126
         }
127 127
         
128 128
         // If the uuid already exists then just send them the record.
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                 'uuid' => $device->uuid,
133 133
                 'id' => $device->id,
134 134
                 'token' => $device->token,
135
-            ]], 200);
135
+            ] ], 200);
136 136
         }
137 137
         
138 138
         // Create the new device.
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $device->save();
143 143
         
144 144
         //Update the new device's name with its id and the current time
145
-        $device->name = $device->name . "_". $device->id . '_' . date('h:ia-e');
145
+        $device->name = $device->name."_".$device->id.'_'.date('h:ia-e');
146 146
         $device->save();
147 147
         
148 148
         // Create an api token for the new device.
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             'uuid' => $device->uuid,
161 161
             'id' => $device->id,
162 162
             'token' => $device->token,
163
-        ]], 201);
163
+        ] ], 201);
164 164
     }
165 165
     
166 166
     /**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         
180 180
         // If validation fails, send the validation error back with status 400.
181 181
         if ($validator->fails()) {
182
-            return response()->json(['data' => $validator->errors()], 400);
182
+            return response()->json([ 'data' => $validator->errors() ], 400);
183 183
         }
184 184
         
185 185
         // Get the device record.
@@ -187,25 +187,25 @@  discard block
 block discarded – undo
187 187
         
188 188
         // If token doesnt match then send 401 unauthorized.
189 189
         if ($request->input('token') != $device->token) {
190
-            return response()->json(['data' => 'Bad token.'], 401);
190
+            return response()->json([ 'data' => 'Bad token.' ], 401);
191 191
         }
192 192
         
193 193
         // Save the image to disk.
194
-        $path = $request->file('image')->storeAs('deviceimage', $device['id'], 'private');
194
+        $path = $request->file('image')->storeAs('deviceimage', $device[ 'id' ], 'private');
195 195
         
196 196
         // Update the url for the image.
197 197
         $deviceimage = Deviceimage::updateOrCreate(
198
-            ['device_id' => $device['id']],
199
-            ['url' => $path]
198
+            [ 'device_id' => $device[ 'id' ] ],
199
+            [ 'url' => $path ]
200 200
         );
201 201
         
202 202
         // Force the updated_at timestamp to update as the url may not change.
203 203
         $deviceimage->touch();
204 204
         
205 205
         return response()->json([ 'data' => [ 
206
-            'id' => $deviceimage['id'],
206
+            'id' => $deviceimage[ 'id' ],
207 207
             'url' => $path,
208
-        ]], 201);
208
+        ] ], 201);
209 209
     }
210 210
 }
211 211
 
Please login to merge, or discard this patch.
app/Notifications/DeviceRegister.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Illuminate\Bus\Queueable;
6 6
 use Illuminate\Notifications\Notification;
7
-use Illuminate\Contracts\Queue\ShouldQueue;
8 7
 use Illuminate\Notifications\Messages\NexmoMessage;
9 8
 
10 9
 class DeviceRegister extends Notification
Please login to merge, or discard this patch.
app/Http/Controllers/DashboardController.php 1 patch
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
-use Illuminate\Http\Request;
6
-use Illuminate\Support\Facades\DB;
7 5
 use App\Device;
8 6
 use App\Site;
9 7
 use App\Location;
Please login to merge, or discard this patch.
app/Site.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function getSitesExclude($id)
44 44
     {
45
-        $sites = self::select(['id', 'name'])
45
+        $sites = self::select([ 'id', 'name' ])
46 46
                         ->where('id', '!=', $id)
47 47
                         ->orderBy('name')->get();
48 48
         return $sites;
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function orderedSitesBy($id)
58 58
     {
59
-        $sites = self::query()->select(['id', 'name'])
60
-                                ->orderByRaw(DB::raw("(id = " . $id . ") DESC"))
59
+        $sites = self::query()->select([ 'id', 'name' ])
60
+                                ->orderByRaw(DB::raw("(id = ".$id.") DESC"))
61 61
                                 ->get();
62 62
         return $sites;
63 63
     }
Please login to merge, or discard this patch.
app/Http/Controllers/DeviceController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function details($id)
113 113
     {
114
-        $device = $this->device_m->select(['id', 'name', 'location_id', 'open_time', 'close_time'])
114
+        $device = $this->device_m->select([ 'id', 'name', 'location_id', 'open_time', 'close_time' ])
115 115
                                     ->findOrFail($id);
116 116
         
117 117
         return $device;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         
180 180
         if ($validator->fails()) {
181 181
             if ($request->input('from') == 'modal')
182
-                return response()->json(['errors'=>$validator->errors()], 422);
182
+                return response()->json([ 'errors'=>$validator->errors() ], 422);
183 183
             else
184 184
                 return redirect('device/'.$id.'/edit')->withErrors($validator)->withInput();
185 185
         }
Please login to merge, or discard this patch.
Braces   +15 added lines, -18 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
         {
81 81
             $sites = $this->site_m->orderedSitesBy($location->site_id);
82 82
             $locations = $this->location_m->orderedSiteLocationsBy($location->site_id, $device->location_id);
83
-        }
84
-        else
83
+        } else
85 84
         {
86 85
             $locations = null;
87 86
             $sites = $this->site_m->all();
@@ -178,10 +177,11 @@  discard block
 block discarded – undo
178 177
         ]);
179 178
         
180 179
         if ($validator->fails()) {
181
-            if ($request->input('from') == 'modal')
182
-                return response()->json(['errors'=>$validator->errors()], 422);
183
-            else
184
-                return redirect('device/'.$id.'/edit')->withErrors($validator)->withInput();
180
+            if ($request->input('from') == 'modal') {
181
+                            return response()->json(['errors'=>$validator->errors()], 422);
182
+            } else {
183
+                            return redirect('device/'.$id.'/edit')->withErrors($validator)->withInput();
184
+            }
185 185
         }
186 186
         
187 187
         $siteNew = !empty($request->input('new_site_name'));
@@ -191,8 +191,7 @@  discard block
 block discarded – undo
191 191
             //Create a new site
192 192
             $siteName = $request->input('new_site_name');
193 193
             $site_id = $this->site_m->createSite($siteName);
194
-        }
195
-        else
194
+        } else
196 195
         {
197 196
             $site_id = $request->input('site');
198 197
         }
@@ -204,8 +203,7 @@  discard block
 block discarded – undo
204 203
             //Create a new location
205 204
             $locationName = $request->input('new_location_name');
206 205
             $location_id = $this->location_m->createLocation($locationName, $site_id);
207
-        }
208
-        else
206
+        } else
209 207
         {
210 208
             $location_id = $request->input('location');
211 209
         }
@@ -220,10 +218,11 @@  discard block
 block discarded – undo
220 218
         //If the old site isn't connected to a device then remove it
221 219
         $this->removeUnusedSite($oldLocationID);
222 220
         
223
-        if ($request->input('from') == 'modal')
224
-            return "Success";
225
-        else
226
-            return redirect('device');
221
+        if ($request->input('from') == 'modal') {
222
+                    return "Success";
223
+        } else {
224
+                    return redirect('device');
225
+        }
227 226
     }
228 227
 
229 228
     /**
@@ -240,8 +239,7 @@  discard block
 block discarded – undo
240 239
         {
241 240
             //If the user was already deleted then permanently delete it
242 241
             $this->device_m->destroy($id);
243
-        }
244
-        else
242
+        } else
245 243
         {
246 244
             //Remove the location from the device
247 245
             $oldLocation_id = $device->location_id;
@@ -287,8 +285,7 @@  discard block
 block discarded – undo
287 285
             {
288 286
                 //Get the site connected to the location and delete it
289 287
                 $this->site_m->findOrFail($site_id)->delete();
290
-            }
291
-            else
288
+            } else
292 289
             {
293 290
                 //Delete the location that isn't used anymore
294 291
                 $oldLocation->delete();
Please login to merge, or discard this patch.