@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use App\Sensor; |
| 6 | 6 | use App\DataTables\SensorDataTable; |
| 7 | 7 | use Illuminate\Http\Request; |
| 8 | -use Validator; |
|
| 9 | 8 | use Charts; |
| 10 | 9 | |
| 11 | 10 | class SensorController extends Controller |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | */ |
| 70 | 70 | public function getLatestDataAttribute() |
| 71 | 71 | { |
| 72 | - return $this->hasOne('App\SensorData')->latest()->first() ?? (object)[]; |
|
| 72 | + return $this->hasOne('App\SensorData')->latest()->first() ?? (object) [ ]; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $device = Device::findOrFail($id); |
| 57 | 57 | |
| 58 | - $charts = []; |
|
| 58 | + $charts = [ ]; |
|
| 59 | 59 | foreach ($device->sensors as $sensor) { |
| 60 | 60 | $data = $sensor->last_month_daily_avg_data; |
| 61 | - $charts[$sensor->id] = Charts::create('line', 'highcharts') |
|
| 61 | + $charts[ $sensor->id ] = Charts::create('line', 'highcharts') |
|
| 62 | 62 | ->title($sensor->name) |
| 63 | 63 | ->elementLabel($sensor->type) |
| 64 | 64 | ->labels($data->pluck('date')) |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $sites = Site::select('id', 'name')->orderByRaw("id = ? DESC", $site_id) |
| 91 | 91 | ->orderBy('name', 'ASC')->get(); |
| 92 | 92 | //Get all locations for the selected site with the selected location first |
| 93 | - $locations = Location::select('id', 'name')->where('site_id', '=', $sites[0]->id ?? 0) |
|
| 93 | + $locations = Location::select('id', 'name')->where('site_id', '=', $sites[ 0 ]->id ?? 0) |
|
| 94 | 94 | ->orderByRaw("id = ? DESC", $location_id)->orderBy('name', 'ASC')->get(); |
| 95 | 95 | |
| 96 | 96 | return view('device.edit', [ 'device' => $device, 'locations' => $locations, 'sites' => $sites ]); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if (!empty($request->input('new_site_name'))) |
| 112 | 112 | { |
| 113 | 113 | //Create a new site |
| 114 | - $site = Site::create(['name' => $request->input('new_site_name')]); |
|
| 114 | + $site = Site::create([ 'name' => $request->input('new_site_name') ]); |
|
| 115 | 115 | $site_id = $site->id; |
| 116 | 116 | } |
| 117 | 117 | else |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | if (!empty($request->input('new_location_name'))) |
| 122 | 122 | { |
| 123 | 123 | //Create a new location |
| 124 | - $location = Location::create(['name' => $request->input('new_location_name'), 'site_id' => $site_id]); |
|
| 124 | + $location = Location::create([ 'name' => $request->input('new_location_name'), 'site_id' => $site_id ]); |
|
| 125 | 125 | $location_id = $location->id; |
| 126 | 126 | } |
| 127 | 127 | else |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | if ($request->command === 'unlock') |
| 149 | 149 | { |
| 150 | 150 | if ($device->isDuringScheduleOpen()) |
| 151 | - $command = 'open'; |
|
| 151 | + $command = 'open'; |
|
| 152 | 152 | else |
| 153 | - $command = 'close'; |
|
| 153 | + $command = 'close'; |
|
| 154 | 154 | } |
| 155 | 155 | $device->cover_command = $command; |
| 156 | 156 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $device->save(); |
| 159 | 159 | |
| 160 | 160 | if (\Request::ajax()) |
| 161 | - return response()->json(['success' => 'Device updated successfully']); |
|
| 161 | + return response()->json([ 'success' => 'Device updated successfully' ]); |
|
| 162 | 162 | else |
| 163 | 163 | return redirect()->route('device.show', $id) |
| 164 | 164 | ->with('success', 'Device updated successfully'); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | return redirect()->route('device.index') |
| 193 | - ->with('success','Device deleted successfully'); |
|
| 193 | + ->with('success', 'Device deleted successfully'); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -206,6 +206,6 @@ discard block |
||
| 206 | 206 | $device->restore(); |
| 207 | 207 | |
| 208 | 208 | return redirect()->route('device.show', $device->id) |
| 209 | - ->with('success','Device restored successfully'); |
|
| 209 | + ->with('success', 'Device restored successfully'); |
|
| 210 | 210 | } |
| 211 | 211 | } |