Completed
Pull Request — master (#34)
by Brandon
12:58 queued 10:54
created
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
-
7 5
 class DashboardController extends Controller
8 6
 {
9 7
     /**
Please login to merge, or discard this patch.
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
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\Database\Eloquent\Model;
6 6
 use Illuminate\Database\Eloquent\SoftDeletes;
7
-use Illuminate\Support\Facades\DB;
8 7
 
9 8
 class Device extends Model
10 9
 {
Please login to merge, or discard this patch.
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.
app/Location.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@
 block discarded – undo
55 55
      */
56 56
     public function orderedSiteLocationsBy($site_id, $location_id)
57 57
     {
58
-        $locations = self::query()->select(['id', 'name'])
58
+        $locations = self::query()->select([ 'id', 'name' ])
59 59
                                     ->where('site_id', '=', $site_id)
60
-                                    ->orderByRaw(DB::raw("(id = " . $location_id . ") DESC"))
60
+                                    ->orderByRaw(DB::raw("(id = ".$location_id.") DESC"))
61 61
                                     ->get();
62 62
         return $locations;
63 63
     }
Please login to merge, or discard this patch.
app/Http/Controllers/DeviceController.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
         {
80 80
             $sites = $this->site_m->orderedSitesBy($location->site_id);
81 81
             $locations = $this->location_m->orderedSiteLocationsBy($location->site_id, $device->location_id);
82
-        }
83
-        else
82
+        } else
84 83
         {
85 84
             $locations = null;
86 85
             $sites = $this->site_m->all();
@@ -141,8 +140,7 @@  discard block
 block discarded – undo
141 140
             //Create a new site
142 141
             $siteName = $request->input('new_site_name');
143 142
             $site_id = $this->site_m->createSite($siteName);
144
-        }
145
-        else
143
+        } else
146 144
         {
147 145
             $site_id = $request->input('site');
148 146
         }
@@ -154,8 +152,7 @@  discard block
 block discarded – undo
154 152
             //Create a new location
155 153
             $locationName = $request->input('new_location_name');
156 154
             $location_id = $this->location_m->createLocation($locationName, $site_id);
157
-        }
158
-        else
155
+        } else
159 156
         {
160 157
             $location_id = $request->input('location');
161 158
         }
@@ -185,8 +182,7 @@  discard block
 block discarded – undo
185 182
         {
186 183
             //If the user was already deleted then permanently delete it
187 184
             $this->device_m->destroy($id);
188
-        }
189
-        else
185
+        } else
190 186
         {
191 187
             //Remove the location from the device
192 188
             $oldLocation_id = $device->location_id;
@@ -232,8 +228,7 @@  discard block
 block discarded – undo
232 228
             {
233 229
                 //Get the site connected to the location and delete it
234 230
                 $this->site_m->findOrFail($site_id)->delete();
235
-            }
236
-            else
231
+            } else
237 232
             {
238 233
                 //Delete the location that isn't used anymore
239 234
                 $oldLocation->delete();
Please login to merge, or discard this patch.
app/Site.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@
 block discarded – undo
42 42
      */
43 43
     public function orderedSitesBy($id)
44 44
     {
45
-        $sites = self::query()->select(['id', 'name'])
46
-                                ->orderByRaw(DB::raw("(id = " . $id . ") DESC"))
45
+        $sites = self::query()->select([ 'id', 'name' ])
46
+                                ->orderByRaw(DB::raw("(id = ".$id.") DESC"))
47 47
                                 ->get();
48 48
         return $sites;
49 49
     }
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.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      */    
19 19
     public function index()
20 20
     {
21
-        return response()->json(['data' => 'SmartSettia API - Bad request type.'], 400);
21
+        return response()->json([ 'data' => 'SmartSettia API - Bad request type.' ], 400);
22 22
     }
23 23
 
24 24
     /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         
63 63
         // If validation fails, send the validation error back with status 400.
64 64
         if ($validator->fails()) {
65
-            return response()->json(['data' => $validator->errors()], 400);
65
+            return response()->json([ 'data' => $validator->errors() ], 400);
66 66
         }
67 67
         
68 68
         // Get the device record.
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         
71 71
         // If token doesnt match then send 401 unauthorized.
72 72
         if ($request->input('token') != $device->token) {
73
-            return response()->json(['data' => 'Bad token.'], 401);
73
+            return response()->json([ 'data' => 'Bad token.' ], 401);
74 74
         }
75 75
         
76 76
         // Update the device.
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         //event(new Registered(true));
101 101
         
102 102
         // Return the new device info including the token.
103
-        return response()->json(['data' => $device->toArray()], 201);
103
+        return response()->json([ 'data' => $device->toArray() ], 201);
104 104
     }
105 105
     
106 106
     /**
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
         
120 120
         // If validation fails, send the validation error back with status 400.
121 121
         if ($validator->fails()) {
122
-            return response()->json(['data' => $validator->errors()], 400);
122
+            return response()->json([ 'data' => $validator->errors() ], 400);
123 123
         }
124 124
         
125 125
         // If challenge string doesnt match then send 401 unauthorized.
126 126
         if ($request->input('challenge') != env('API_CHALLENGE', 'temppass')) {
127
-            return response()->json(['data' => 'Bad challenge.'], 401);
127
+            return response()->json([ 'data' => 'Bad challenge.' ], 401);
128 128
         }
129 129
         
130 130
         // If the uuid already exists then just send them the record.
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 'uuid' => $device->uuid,
135 135
                 'id' => $device->id,
136 136
                 'token' => $device->token,
137
-            ]], 200);
137
+            ] ], 200);
138 138
         }
139 139
         
140 140
         // Create the new device.
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             'uuid' => $device->uuid,
158 158
             'id' => $device->id,
159 159
             'token' => $device->token,
160
-        ]], 201);
160
+        ] ], 201);
161 161
     }
162 162
     
163 163
     /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         
177 177
         // If validation fails, send the validation error back with status 400.
178 178
         if ($validator->fails()) {
179
-            return response()->json(['data' => $validator->errors()], 400);
179
+            return response()->json([ 'data' => $validator->errors() ], 400);
180 180
         }
181 181
         
182 182
         // Get the device record.
@@ -184,25 +184,25 @@  discard block
 block discarded – undo
184 184
         
185 185
         // If token doesnt match then send 401 unauthorized.
186 186
         if ($request->input('token') != $device->token) {
187
-            return response()->json(['data' => 'Bad token.'], 401);
187
+            return response()->json([ 'data' => 'Bad token.' ], 401);
188 188
         }
189 189
         
190 190
         // Save the image to disk.
191
-        $path = $request->file('image')->storeAs('deviceimage', $device['id'], 'private');
191
+        $path = $request->file('image')->storeAs('deviceimage', $device[ 'id' ], 'private');
192 192
         
193 193
         // Update the url for the image.
194 194
         $deviceimage = Deviceimage::updateOrCreate(
195
-            ['device_id' => $device['id']],
196
-            ['url' => $path]
195
+            [ 'device_id' => $device[ 'id' ] ],
196
+            [ 'url' => $path ]
197 197
         );
198 198
         
199 199
         // Force the updated_at timestamp to update as the url may not change.
200 200
         $deviceimage->touch();
201 201
         
202 202
         return response()->json([ 'data' => [ 
203
-            'id' => $deviceimage['id'],
203
+            'id' => $deviceimage[ 'id' ],
204 204
             'url' => $path,
205
-        ]], 201);
205
+        ] ], 201);
206 206
     }
207 207
 }
208 208
 
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.