@@ -30,7 +30,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $time = new Carbon($value, 'UTC'); |
| 76 | 76 | |
| 77 | 77 | //If the user is logged in then use there preferred timezone |
| 78 | - if (Auth::check()) |
|
| 79 | - $time = $time->setTimezone(Auth::user()->timezone); |
|
| 78 | + if (Auth::check()) { |
|
| 79 | + $time = $time->setTimezone(Auth::user()->timezone); |
|
| 80 | + } |
|
| 80 | 81 | |
| 81 | 82 | return $time->format('H:i'); |
| 82 | 83 | } |
@@ -94,8 +95,9 @@ discard block |
||
| 94 | 95 | $time = new Carbon($value, 'UTC'); |
| 95 | 96 | |
| 96 | 97 | //If the user is logged in then use there preferred timezone |
| 97 | - if (Auth::check()) |
|
| 98 | - $time = $time->setTimezone(Auth::user()->timezone); |
|
| 98 | + if (Auth::check()) { |
|
| 99 | + $time = $time->setTimezone(Auth::user()->timezone); |
|
| 100 | + } |
|
| 99 | 101 | |
| 100 | 102 | return $time->format('H:i'); |
| 101 | 103 | } |
@@ -115,9 +117,9 @@ discard block |
||
| 115 | 117 | { |
| 116 | 118 | $time = new Carbon($value, Auth::user()->timezone); |
| 117 | 119 | $time = $time->setTimezone('UTC'); |
| 120 | + } else { |
|
| 121 | + $time = new Carbon($value, 'UTC'); |
|
| 118 | 122 | } |
| 119 | - else |
|
| 120 | - $time = new Carbon($value, 'UTC'); |
|
| 121 | 123 | |
| 122 | 124 | $this->attributes['open_time'] = $time; |
| 123 | 125 | } |
@@ -137,9 +139,9 @@ discard block |
||
| 137 | 139 | { |
| 138 | 140 | $time = new Carbon($value, Auth::user()->timezone); |
| 139 | 141 | $time = $time->setTimezone('UTC'); |
| 142 | + } else { |
|
| 143 | + $time = new Carbon($value, 'UTC'); |
|
| 140 | 144 | } |
| 141 | - else |
|
| 142 | - $time = new Carbon($value, 'UTC'); |
|
| 143 | 145 | |
| 144 | 146 | $this->attributes['close_time'] = $time; |
| 145 | 147 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @var array |
| 33 | 33 | */ |
| 34 | - protected $hidden = ['token']; |
|
| 34 | + protected $hidden = [ 'token' ]; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * The attributes that are mass assignable. |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @var array |
| 52 | 52 | */ |
| 53 | - protected static $ignoreChangedAttributes = ['updated_at']; |
|
| 53 | + protected static $ignoreChangedAttributes = [ 'updated_at' ]; |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * The attributes to log in the Activity Log |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function getSiteAttribute() |
| 93 | 93 | { |
| 94 | - return $this->location->site ?? (object)[]; |
|
| 94 | + return $this->location->site ?? (object) [ ]; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | else |
| 152 | 152 | $time = new Carbon($value, 'UTC'); |
| 153 | 153 | |
| 154 | - $this->attributes['open_time'] = $time; |
|
| 154 | + $this->attributes[ 'open_time' ] = $time; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | else |
| 174 | 174 | $time = new Carbon($value, 'UTC'); |
| 175 | 175 | |
| 176 | - $this->attributes['close_time'] = $time; |
|
| 176 | + $this->attributes[ 'close_time' ] = $time; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected static $ignoreChangedAttributes = ['updated_at']; |
|
| 27 | + protected static $ignoreChangedAttributes = [ 'updated_at' ]; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The attributes to log in the Activity Log |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected static $ignoreChangedAttributes = ['updated_at']; |
|
| 27 | + protected static $ignoreChangedAttributes = [ 'updated_at' ]; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The attributes to log in the Activity Log |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected static $ignoreChangedAttributes = ['updated_at']; |
|
| 27 | + protected static $ignoreChangedAttributes = [ 'updated_at' ]; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The attributes to log in the Activity Log |
@@ -84,8 +84,7 @@ discard block |
||
| 84 | 84 | $sites->prepend($location->site); |
| 85 | 85 | //Add the current location to the front of the collection of locations |
| 86 | 86 | $locations->prepend($location); |
| 87 | - } |
|
| 88 | - else |
|
| 87 | + } else |
|
| 89 | 88 | { |
| 90 | 89 | //Set locations to null since there is no site or location attached to the selected device |
| 91 | 90 | $locations = null; |
@@ -93,10 +92,11 @@ discard block |
||
| 93 | 92 | $sites = Site::all(); |
| 94 | 93 | } |
| 95 | 94 | |
| 96 | - if (\Request::ajax()) |
|
| 97 | - return response()->json([ 'device' => $device, 'locations' => $locations, 'sites' => $sites ]); |
|
| 98 | - else |
|
| 99 | - return view('device.edit', [ 'device' => $device, 'locations' => $locations, 'sites' => $sites ]); |
|
| 95 | + if (\Request::ajax()) { |
|
| 96 | + return response()->json([ 'device' => $device, 'locations' => $locations, 'sites' => $sites ]); |
|
| 97 | + } else { |
|
| 98 | + return view('device.edit', [ 'device' => $device, 'locations' => $locations, 'sites' => $sites ]); |
|
| 99 | + } |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -110,8 +110,9 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $locations = Location::bySite($site_id)->select('id', 'name', 'site_id')->get(); |
| 112 | 112 | |
| 113 | - if ($locations->isEmpty()) |
|
| 114 | - $locations = null; |
|
| 113 | + if ($locations->isEmpty()) { |
|
| 114 | + $locations = null; |
|
| 115 | + } |
|
| 115 | 116 | |
| 116 | 117 | return response()->json($locations); |
| 117 | 118 | } |
@@ -151,8 +152,7 @@ discard block |
||
| 151 | 152 | //Create a new site |
| 152 | 153 | $siteName = $request->input('new_site_name'); |
| 153 | 154 | $site_id = Site::createSite($siteName)->id; |
| 154 | - } |
|
| 155 | - else |
|
| 155 | + } else |
|
| 156 | 156 | { |
| 157 | 157 | $site_id = $request->input('site'); |
| 158 | 158 | } |
@@ -166,8 +166,7 @@ discard block |
||
| 166 | 166 | //Create a new location |
| 167 | 167 | $locationName = $request->input('new_location_name'); |
| 168 | 168 | $location_id = Location::createLocation($locationName, $site_id)->id; |
| 169 | - } |
|
| 170 | - else |
|
| 169 | + } else |
|
| 171 | 170 | { |
| 172 | 171 | $location_id = $request->input('location'); |
| 173 | 172 | } |
@@ -188,10 +187,11 @@ discard block |
||
| 188 | 187 | //Remove any unused sites or locations |
| 189 | 188 | $this->RemoveUnusedSiteLoc(); |
| 190 | 189 | |
| 191 | - if (\Request::ajax()) |
|
| 192 | - return response()->json("Success"); |
|
| 193 | - else |
|
| 194 | - return redirect('device'); |
|
| 190 | + if (\Request::ajax()) { |
|
| 191 | + return response()->json("Success"); |
|
| 192 | + } else { |
|
| 193 | + return redirect('device'); |
|
| 194 | + } |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -208,8 +208,7 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | //If the device was already deleted then permanently delete it |
| 210 | 210 | Device::destroy($id); |
| 211 | - } |
|
| 212 | - else |
|
| 211 | + } else |
|
| 213 | 212 | { |
| 214 | 213 | //Remove the location from the device |
| 215 | 214 | $device->location_id = null; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | //Get the first device that doesn't have a null location_id |
| 36 | 36 | $device = Device::publicDashData()->where('location_id', '!=', 'null')->orderBy('id', 'ASC')->first(); |
| 37 | 37 | } |
| 38 | - catch(ModelNotFoundException $e) |
|
| 38 | + catch (ModelNotFoundException $e) |
|
| 39 | 39 | { |
| 40 | 40 | //If no device is found then redirect the user to the home page and display a message about registering a device |
| 41 | 41 | return redirect('home')->with('no_devices', 'To access the dashboard page there must be at least one registered device assigned to a location.'); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $data = $this->dashData($site, $location, $device); |
| 50 | 50 | |
| 51 | - return view('dashboard.index', [ 'active_device' => $data[0], 'devices' => $data[1], 'locations' => $data[2], 'sites' => $data[3] ]); |
|
| 51 | + return view('dashboard.index', [ 'active_device' => $data[ 0 ], 'devices' => $data[ 1 ], 'locations' => $data[ 2 ], 'sites' => $data[ 3 ] ]); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | //Get the first site and if no sites exist throw an error |
| 93 | 93 | $site = Site::select('id', 'name')->firstOrFail(); |
| 94 | 94 | } |
| 95 | - catch(ModelNotFoundException $e) |
|
| 95 | + catch (ModelNotFoundException $e) |
|
| 96 | 96 | { |
| 97 | 97 | //If no device is found then redirect the user to the home page and display a message about registering a device |
| 98 | 98 | return redirect('home')->with('no_devices', 'To access the dashboard page there must be at least one registered device assigned to a location.'); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $data = $this->dashData($site, $location, $device); |
| 120 | 120 | |
| 121 | - return response()->json([ 'active_device' => $data[0], 'devices' => $data[1], 'locations' => $data[2], 'sites' => $data[3] ]); |
|
| 121 | + return response()->json([ 'active_device' => $data[ 0 ], 'devices' => $data[ 1 ], 'locations' => $data[ 2 ], 'sites' => $data[ 3 ] ]); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $data = $this->dashData($site, $location, $device); |
| 140 | 140 | |
| 141 | - return response()->json([ 'active_device' => $data[0], 'devices' => $data[1], 'locations' => $data[2], 'sites' => $data[3] ]); |
|
| 141 | + return response()->json([ 'active_device' => $data[ 0 ], 'devices' => $data[ 1 ], 'locations' => $data[ 2 ], 'sites' => $data[ 3 ] ]); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $data = $this->dashData($site, $location, $device); |
| 160 | 160 | |
| 161 | - return response()->json([ 'active_device' => $data[0], 'devices' => $data[1], 'locations' => $data[2], 'sites' => $data[3] ]); |
|
| 161 | + return response()->json([ 'active_device' => $data[ 0 ], 'devices' => $data[ 1 ], 'locations' => $data[ 2 ], 'sites' => $data[ 3 ] ]); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | //Get all the devices that belong to the given location ordered by name |
| 181 | 181 | $devices = $location->devices()->publicDashData()->orderBy('name', 'ASC')->get(); |
| 182 | 182 | |
| 183 | - $active_device = collect([$device, $location, $site]); |
|
| 183 | + $active_device = collect([ $device, $location, $site ]); |
|
| 184 | 184 | |
| 185 | - return collect([$active_device, $devices, $locations, $sites]); |
|
| 185 | + return collect([ $active_device, $devices, $locations, $sites ]); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | return response()->json("Device is currently in use.", 403); |
| 204 | 204 | |
| 205 | 205 | //1 = open, 2 = close, 3 = lock |
| 206 | - switch($request->command) |
|
| 206 | + switch ($request->command) |
|
| 207 | 207 | { |
| 208 | 208 | case 1: |
| 209 | 209 | $device->cover_command = 'open'; |
@@ -239,12 +239,12 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | //Check if the current time is during the open schedule or not |
| 241 | 241 | if (($time_now > $open_time) && ($time_now < $close_time)) |
| 242 | - $command = 'open'; |
|
| 242 | + $command = 'open'; |
|
| 243 | 243 | else |
| 244 | - $command = 'close'; |
|
| 244 | + $command = 'close'; |
|
| 245 | 245 | } |
| 246 | 246 | else |
| 247 | - $command = 'lock'; |
|
| 247 | + $command = 'lock'; |
|
| 248 | 248 | |
| 249 | 249 | return $command; |
| 250 | 250 | } |
@@ -34,8 +34,7 @@ discard block |
||
| 34 | 34 | //Todo use the users preferred device |
| 35 | 35 | //Get the first device that doesn't have a null location_id |
| 36 | 36 | $device = Device::publicDashData()->where('location_id', '!=', 'null')->orderBy('id', 'ASC')->first(); |
| 37 | - } |
|
| 38 | - catch(ModelNotFoundException $e) |
|
| 37 | + } catch(ModelNotFoundException $e) |
|
| 39 | 38 | { |
| 40 | 39 | //If no device is found then redirect the user to the home page and display a message about registering a device |
| 41 | 40 | return redirect('home')->with('no_devices', 'To access the dashboard page there must be at least one registered device assigned to a location.'); |
@@ -85,14 +84,15 @@ discard block |
||
| 85 | 84 | //Get the given device if it is still at the same location |
| 86 | 85 | $device = Device::publicDashData()->where('location_id', '=', $request->location_id)->find($request->device_id); |
| 87 | 86 | |
| 88 | - if (empty($site)) //Check if the site still exists |
|
| 87 | + if (empty($site)) { |
|
| 88 | + //Check if the site still exists |
|
| 89 | 89 | { |
| 90 | 90 | try |
| 91 | 91 | { |
| 92 | 92 | //Get the first site and if no sites exist throw an error |
| 93 | 93 | $site = Site::select('id', 'name')->firstOrFail(); |
| 94 | - } |
|
| 95 | - catch(ModelNotFoundException $e) |
|
| 94 | + } |
|
| 95 | + } catch(ModelNotFoundException $e) |
|
| 96 | 96 | { |
| 97 | 97 | //If no device is found then redirect the user to the home page and display a message about registering a device |
| 98 | 98 | return redirect('home')->with('no_devices', 'To access the dashboard page there must be at least one registered device assigned to a location.'); |
@@ -102,19 +102,21 @@ discard block |
||
| 102 | 102 | $location = $site->locations()->select('id', 'name', 'site_id')->firstOrFail(); |
| 103 | 103 | //Get the first device from the location |
| 104 | 104 | $device = $location->devices()->publicDashData()->firstOrFail(); |
| 105 | - } |
|
| 106 | - else if (empty($location)) //Check if the location still exists |
|
| 105 | + } else if (empty($location)) { |
|
| 106 | + //Check if the location still exists |
|
| 107 | 107 | { |
| 108 | 108 | //Get the first location from the given site |
| 109 | 109 | $location = $site->locations()->select('id', 'name', 'site_id')->firstOrFail(); |
| 110 | + } |
|
| 110 | 111 | //Get the first device from the location |
| 111 | 112 | $device = $location->devices()->publicDashData()->firstOrFail(); |
| 112 | - } |
|
| 113 | - else if (empty($device)) //Check if the device still exists at the given location |
|
| 113 | + } else if (empty($device)) { |
|
| 114 | + //Check if the device still exists at the given location |
|
| 114 | 115 | { |
| 115 | 116 | //Get the first device from the location |
| 116 | 117 | $device = $location->devices()->publicDashData()->firstOrFail(); |
| 117 | 118 | } |
| 119 | + } |
|
| 118 | 120 | |
| 119 | 121 | $data = $this->dashData($site, $location, $device); |
| 120 | 122 | |
@@ -199,8 +201,9 @@ discard block |
||
| 199 | 201 | ])->validate(); |
| 200 | 202 | |
| 201 | 203 | //Check that device isn't currently in use or has an error |
| 202 | - if ($device->cover_status === 'opening' || $device->cover_status === 'closing' || $device->cover_status === 'error') |
|
| 203 | - return response()->json("Device is currently in use.", 403); |
|
| 204 | + if ($device->cover_status === 'opening' || $device->cover_status === 'closing' || $device->cover_status === 'error') { |
|
| 205 | + return response()->json("Device is currently in use.", 403); |
|
| 206 | + } |
|
| 204 | 207 | |
| 205 | 208 | //1 = open, 2 = close, 3 = lock |
| 206 | 209 | switch($request->command) |
@@ -238,13 +241,14 @@ discard block |
||
| 238 | 241 | $time_now = Carbon::now(Auth::user()->timezone); |
| 239 | 242 | |
| 240 | 243 | //Check if the current time is during the open schedule or not |
| 241 | - if (($time_now > $open_time) && ($time_now < $close_time)) |
|
| 242 | - $command = 'open'; |
|
| 243 | - else |
|
| 244 | - $command = 'close'; |
|
| 244 | + if (($time_now > $open_time) && ($time_now < $close_time)) { |
|
| 245 | + $command = 'open'; |
|
| 246 | + } else { |
|
| 247 | + $command = 'close'; |
|
| 248 | + } |
|
| 249 | + } else { |
|
| 250 | + $command = 'lock'; |
|
| 245 | 251 | } |
| 246 | - else |
|
| 247 | - $command = 'lock'; |
|
| 248 | 252 | |
| 249 | 253 | return $command; |
| 250 | 254 | } |
@@ -143,6 +143,6 @@ |
||
| 143 | 143 | public function roleString() |
| 144 | 144 | { |
| 145 | 145 | $role_en = array(0 => "Registered", 1 => "User", 2 => "Manager", 3 => "Admin"); |
| 146 | - return $role_en[ $this->role ] . ' (' . $this->role . ')'; |
|
| 146 | + return $role_en[ $this->role ].' ('.$this->role.')'; |
|
| 147 | 147 | } |
| 148 | 148 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function index() |
| 23 | 23 | { |
| 24 | - return response()->json(['data' => 'SmartSettia API - Bad request type.'], 400); |
|
| 24 | + return response()->json([ 'data' => 'SmartSettia API - Bad request type.' ], 400); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | //event(new Registered(true)); |
| 91 | 91 | |
| 92 | 92 | // Return the new device info including the token. |
| 93 | - return response()->json(['data' => $device->toArray()], 201); |
|
| 93 | + return response()->json([ 'data' => $device->toArray() ], 201); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | foreach ($sensor_datas as $sensor_data) { |
| 128 | 128 | $sensor = Sensor::firstOrCreate([ |
| 129 | 129 | "device_id" => $device->id, |
| 130 | - "name" => $sensor_data['name'], |
|
| 131 | - "type" => $sensor_data['type'] |
|
| 130 | + "name" => $sensor_data[ 'name' ], |
|
| 131 | + "type" => $sensor_data[ 'type' ] |
|
| 132 | 132 | ]); |
| 133 | 133 | |
| 134 | 134 | SensorData::create([ |
| 135 | 135 | "sensor_id" => $sensor->id, |
| 136 | - "value" => $sensor_data['value'] |
|
| 136 | + "value" => $sensor_data[ 'value' ] |
|
| 137 | 137 | ]); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | //event(new Registered(true)); |
| 144 | 144 | |
| 145 | 145 | // Return the new device info including the token. |
| 146 | - return response()->json(['data' => $device->toArray()], 201); |
|
| 146 | + return response()->json([ 'data' => $device->toArray() ], 201); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | // If challenge string doesnt match then send 401 unauthorized. |
| 164 | 164 | if ($request->input('challenge') != env('API_CHALLENGE', 'temppass')) { |
| 165 | - return response()->json(['data' => 'Bad challenge.'], 401); |
|
| 165 | + return response()->json([ 'data' => 'Bad challenge.' ], 401); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // If the uuid already exists then just send them the record. |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | 'uuid' => $device->uuid, |
| 173 | 173 | 'id' => $device->id, |
| 174 | 174 | 'token' => $device->token, |
| 175 | - ]], 200); |
|
| 175 | + ] ], 200); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // Create the new device. |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | 'uuid' => $device->uuid, |
| 197 | 197 | 'id' => $device->id, |
| 198 | 198 | 'token' => $device->token, |
| 199 | - ]], 201); |
|
| 199 | + ] ], 201); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -217,21 +217,21 @@ discard block |
||
| 217 | 217 | $device = Device::getDeviceByUUID($request->input('uuid')); |
| 218 | 218 | |
| 219 | 219 | // Save the image to disk. |
| 220 | - $path = $request->file('image')->storeAs('deviceimage', $device['id'], 'private'); |
|
| 220 | + $path = $request->file('image')->storeAs('deviceimage', $device[ 'id' ], 'private'); |
|
| 221 | 221 | |
| 222 | 222 | // Update the url for the image. |
| 223 | 223 | $deviceimage = Deviceimage::updateOrCreate( |
| 224 | - ['device_id' => $device['id']], |
|
| 225 | - ['url' => $path] |
|
| 224 | + [ 'device_id' => $device[ 'id' ] ], |
|
| 225 | + [ 'url' => $path ] |
|
| 226 | 226 | ); |
| 227 | 227 | |
| 228 | 228 | // Force the updated_at timestamp to update as the url may not change. |
| 229 | 229 | $deviceimage->touch(); |
| 230 | 230 | |
| 231 | 231 | return response()->json([ 'data' => [ |
| 232 | - 'id' => $deviceimage['id'], |
|
| 232 | + 'id' => $deviceimage[ 'id' ], |
|
| 233 | 233 | 'url' => $path, |
| 234 | - ]], 201); |
|
| 234 | + ] ], 201); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |