@@ -10,7 +10,7 @@ |
||
10 | 10 | /** |
11 | 11 | * Returns the count of all pokes. |
12 | 12 | * |
13 | - * @return mixed |
|
13 | + * @return integer |
|
14 | 14 | */ |
15 | 15 | public function totalPokes() |
16 | 16 | { |
@@ -9,60 +9,60 @@ |
||
9 | 9 | |
10 | 10 | class Statistics |
11 | 11 | { |
12 | - /** |
|
13 | - * Returns the count of all pokes. |
|
14 | - * |
|
15 | - * @return mixed |
|
16 | - */ |
|
17 | - public function totalPokes() |
|
18 | - { |
|
19 | - $base = 189771; |
|
12 | + /** |
|
13 | + * Returns the count of all pokes. |
|
14 | + * |
|
15 | + * @return mixed |
|
16 | + */ |
|
17 | + public function totalPokes() |
|
18 | + { |
|
19 | + $base = 189771; |
|
20 | 20 | |
21 | - return DB::table('network_distribution')->sum('pokes') + $base; |
|
22 | - } |
|
21 | + return DB::table('network_distribution')->sum('pokes') + $base; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * Returns the the count of all devices. |
|
26 | - * |
|
27 | - * @return mixed |
|
28 | - */ |
|
29 | - public function totalDevices() |
|
30 | - { |
|
31 | - return DeviceArchive::count(); |
|
32 | - } |
|
24 | + /** |
|
25 | + * Returns the the count of all devices. |
|
26 | + * |
|
27 | + * @return mixed |
|
28 | + */ |
|
29 | + public function totalDevices() |
|
30 | + { |
|
31 | + return DeviceArchive::count(); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Returns all pokes. |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
39 | - public function allPokes() |
|
40 | - { |
|
41 | - return Poke::all(); |
|
42 | - } |
|
34 | + /** |
|
35 | + * Returns all pokes. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function allPokes() |
|
40 | + { |
|
41 | + return Poke::all(); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Returns a collection of all networks and it's count. |
|
46 | - * |
|
47 | - * @return mixed |
|
48 | - */ |
|
49 | - public function networkDistribution() |
|
50 | - { |
|
51 | - $data = DB::table('network_distribution') |
|
52 | - ->select('network as label', 'pokes as value') |
|
53 | - ->get(); |
|
44 | + /** |
|
45 | + * Returns a collection of all networks and it's count. |
|
46 | + * |
|
47 | + * @return mixed |
|
48 | + */ |
|
49 | + public function networkDistribution() |
|
50 | + { |
|
51 | + $data = DB::table('network_distribution') |
|
52 | + ->select('network as label', 'pokes as value') |
|
53 | + ->get(); |
|
54 | 54 | |
55 | - return $this->addColors($data); |
|
56 | - } |
|
55 | + return $this->addColors($data); |
|
56 | + } |
|
57 | 57 | |
58 | - private function addColors($data) |
|
59 | - { |
|
60 | - $colors = ['rgb(23,103,153)', 'rgb(47,135,176)', 'rgb(66,164,187)', 'rgb(91,192,196)']; |
|
61 | - $highlight_colors = ['#8BB3CC', '#97C3D7', '#ADDFE1', '#BBEAE3']; |
|
58 | + private function addColors($data) |
|
59 | + { |
|
60 | + $colors = ['rgb(23,103,153)', 'rgb(47,135,176)', 'rgb(66,164,187)', 'rgb(91,192,196)']; |
|
61 | + $highlight_colors = ['#8BB3CC', '#97C3D7', '#ADDFE1', '#BBEAE3']; |
|
62 | 62 | |
63 | - return $data->each(function ($network, $i) use ($colors, $highlight_colors) { |
|
64 | - $network->color = $colors[$i]; |
|
65 | - $network->highlight = $highlight_colors[$i]; |
|
66 | - }); |
|
67 | - } |
|
63 | + return $data->each(function ($network, $i) use ($colors, $highlight_colors) { |
|
64 | + $network->color = $colors[$i]; |
|
65 | + $network->highlight = $highlight_colors[$i]; |
|
66 | + }); |
|
67 | + } |
|
68 | 68 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $colors = ['rgb(23,103,153)', 'rgb(47,135,176)', 'rgb(66,164,187)', 'rgb(91,192,196)']; |
61 | 61 | $highlight_colors = ['#8BB3CC', '#97C3D7', '#ADDFE1', '#BBEAE3']; |
62 | 62 | |
63 | - return $data->each(function ($network, $i) use ($colors, $highlight_colors) { |
|
63 | + return $data->each(function($network, $i) use ($colors, $highlight_colors) { |
|
64 | 64 | $network->color = $colors[$i]; |
65 | 65 | $network->highlight = $highlight_colors[$i]; |
66 | 66 | }); |
@@ -8,71 +8,71 @@ |
||
8 | 8 | |
9 | 9 | class FlushOldDevices extends Command |
10 | 10 | { |
11 | - /** |
|
12 | - * The console command name. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $name = 'pi:flush'; |
|
11 | + /** |
|
12 | + * The console command name. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $name = 'pi:flush'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * The console command description. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $description = 'Remove all devices from the list which don\'t poked us in the last 15 minutes.'; |
|
18 | + /** |
|
19 | + * The console command description. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $description = 'Remove all devices from the list which don\'t poked us in the last 15 minutes.'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Create a new command instance. |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - parent::__construct(); |
|
31 | - } |
|
25 | + /** |
|
26 | + * Create a new command instance. |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Execute the console command. |
|
35 | - * |
|
36 | - * @return mixed |
|
37 | - */ |
|
38 | - public function fire() |
|
39 | - { |
|
40 | - $affectedRows = $this->getDevices(); |
|
33 | + /** |
|
34 | + * Execute the console command. |
|
35 | + * |
|
36 | + * @return mixed |
|
37 | + */ |
|
38 | + public function fire() |
|
39 | + { |
|
40 | + $affectedRows = $this->getDevices(); |
|
41 | 41 | |
42 | - $message = $this->getMessage($affectedRows); |
|
42 | + $message = $this->getMessage($affectedRows); |
|
43 | 43 | |
44 | - $this->info($message); |
|
45 | - } |
|
44 | + $this->info($message); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param $affectedRows |
|
49 | - * |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function getMessage($affectedRows) |
|
53 | - { |
|
54 | - $message = "Deleted $affectedRows device".($affectedRows == 1 ? '' : 's').'.'; |
|
47 | + /** |
|
48 | + * @param $affectedRows |
|
49 | + * |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function getMessage($affectedRows) |
|
53 | + { |
|
54 | + $message = "Deleted $affectedRows device".($affectedRows == 1 ? '' : 's').'.'; |
|
55 | 55 | |
56 | - return $message; |
|
57 | - } |
|
56 | + return $message; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Get all devices which should get deleted. |
|
61 | - * |
|
62 | - * @return mixed |
|
63 | - */ |
|
64 | - public function getDevices() |
|
65 | - { |
|
66 | - $date = Carbon::now()->subMinutes(15); |
|
59 | + /** |
|
60 | + * Get all devices which should get deleted. |
|
61 | + * |
|
62 | + * @return mixed |
|
63 | + */ |
|
64 | + public function getDevices() |
|
65 | + { |
|
66 | + $date = Carbon::now()->subMinutes(15); |
|
67 | 67 | |
68 | - $devices = Device::where('updated_at', '<', $date)->get(); |
|
68 | + $devices = Device::where('updated_at', '<', $date)->get(); |
|
69 | 69 | |
70 | - $affectedRows = $devices->count(); |
|
70 | + $affectedRows = $devices->count(); |
|
71 | 71 | |
72 | - foreach ($devices as $device) { |
|
73 | - $device->delete(); |
|
74 | - } |
|
72 | + foreach ($devices as $device) { |
|
73 | + $device->delete(); |
|
74 | + } |
|
75 | 75 | |
76 | - return $affectedRows; |
|
77 | - } |
|
76 | + return $affectedRows; |
|
77 | + } |
|
78 | 78 | } |
@@ -9,83 +9,83 @@ |
||
9 | 9 | |
10 | 10 | class UserCreate extends Command |
11 | 11 | { |
12 | - /** |
|
13 | - * The console command name. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $name = 'user:create'; |
|
12 | + /** |
|
13 | + * The console command name. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $name = 'user:create'; |
|
18 | 18 | |
19 | - /** |
|
20 | - * The console command description. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $description = 'Create a user.'; |
|
19 | + /** |
|
20 | + * The console command description. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $description = 'Create a user.'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * The registrar implementation. |
|
28 | - * |
|
29 | - * @var Registrar |
|
30 | - */ |
|
31 | - private $registrar; |
|
26 | + /** |
|
27 | + * The registrar implementation. |
|
28 | + * |
|
29 | + * @var Registrar |
|
30 | + */ |
|
31 | + private $registrar; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Create a new command instance. |
|
35 | - * |
|
36 | - * @param Registrar $registrar |
|
37 | - */ |
|
38 | - public function __construct(Registrar $registrar) |
|
39 | - { |
|
40 | - parent::__construct(); |
|
33 | + /** |
|
34 | + * Create a new command instance. |
|
35 | + * |
|
36 | + * @param Registrar $registrar |
|
37 | + */ |
|
38 | + public function __construct(Registrar $registrar) |
|
39 | + { |
|
40 | + parent::__construct(); |
|
41 | 41 | |
42 | - $this->registrar = $registrar; |
|
43 | - } |
|
42 | + $this->registrar = $registrar; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Execute the console command. |
|
47 | - * |
|
48 | - * @return mixed |
|
49 | - */ |
|
50 | - public function fire() |
|
51 | - { |
|
52 | - $email = $this->argument('email'); |
|
53 | - $password = $this->option('password'); |
|
54 | - $password_confirmation = $this->option('password_confirmation'); |
|
45 | + /** |
|
46 | + * Execute the console command. |
|
47 | + * |
|
48 | + * @return mixed |
|
49 | + */ |
|
50 | + public function fire() |
|
51 | + { |
|
52 | + $email = $this->argument('email'); |
|
53 | + $password = $this->option('password'); |
|
54 | + $password_confirmation = $this->option('password_confirmation'); |
|
55 | 55 | |
56 | - if (!$password) { |
|
57 | - $password = $this->secret('What password should the user have?'); |
|
58 | - } |
|
56 | + if (!$password) { |
|
57 | + $password = $this->secret('What password should the user have?'); |
|
58 | + } |
|
59 | 59 | |
60 | - if (!$password_confirmation) { |
|
61 | - $password_confirmation = $this->secret('Please confirm the password.'); |
|
62 | - } |
|
60 | + if (!$password_confirmation) { |
|
61 | + $password_confirmation = $this->secret('Please confirm the password.'); |
|
62 | + } |
|
63 | 63 | |
64 | - $this->registrar->create(compact('email', 'password', 'password_confirmation')); |
|
65 | - } |
|
64 | + $this->registrar->create(compact('email', 'password', 'password_confirmation')); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Get the console command arguments. |
|
69 | - * |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - protected function getArguments() |
|
73 | - { |
|
74 | - return [ |
|
75 | - ['email', InputArgument::REQUIRED, 'The email address of the user.'], |
|
76 | - ]; |
|
77 | - } |
|
67 | + /** |
|
68 | + * Get the console command arguments. |
|
69 | + * |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + protected function getArguments() |
|
73 | + { |
|
74 | + return [ |
|
75 | + ['email', InputArgument::REQUIRED, 'The email address of the user.'], |
|
76 | + ]; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Get the console command options. |
|
81 | - * |
|
82 | - * @return array |
|
83 | - */ |
|
84 | - protected function getOptions() |
|
85 | - { |
|
86 | - return [ |
|
87 | - ['password', null, InputOption::VALUE_OPTIONAL, 'The password for the user.', null], |
|
88 | - ['password_confirmation', null, InputOption::VALUE_OPTIONAL, 'Password confirmation.', null], |
|
89 | - ]; |
|
90 | - } |
|
79 | + /** |
|
80 | + * Get the console command options. |
|
81 | + * |
|
82 | + * @return array |
|
83 | + */ |
|
84 | + protected function getOptions() |
|
85 | + { |
|
86 | + return [ |
|
87 | + ['password', null, InputOption::VALUE_OPTIONAL, 'The password for the user.', null], |
|
88 | + ['password_confirmation', null, InputOption::VALUE_OPTIONAL, 'Password confirmation.', null], |
|
89 | + ]; |
|
90 | + } |
|
91 | 91 | } |
@@ -9,48 +9,48 @@ |
||
9 | 9 | |
10 | 10 | class UserDelete extends Command |
11 | 11 | { |
12 | - /** |
|
13 | - * The console command name. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $name = 'user:delete'; |
|
18 | - |
|
19 | - /** |
|
20 | - * The console command description. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $description = 'Delete a user.'; |
|
25 | - |
|
26 | - /** |
|
27 | - * Execute the console command. |
|
28 | - * |
|
29 | - * @return mixed |
|
30 | - */ |
|
31 | - public function fire() |
|
32 | - { |
|
33 | - $email = $this->argument('email'); |
|
34 | - |
|
35 | - try { |
|
36 | - $user = User::whereEmail($email)->firstOrFail(); |
|
37 | - $user->delete(); |
|
38 | - |
|
39 | - $this->info('User deleted.'); |
|
40 | - } catch (ModelNotFoundException $e) { |
|
41 | - $this->error('Did not find a user with the given email address'); |
|
42 | - } |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Get the console command arguments. |
|
47 | - * |
|
48 | - * @return array |
|
49 | - */ |
|
50 | - protected function getArguments() |
|
51 | - { |
|
52 | - return [ |
|
53 | - ['email', InputArgument::REQUIRED, 'The email address of the user.'], |
|
54 | - ]; |
|
55 | - } |
|
12 | + /** |
|
13 | + * The console command name. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $name = 'user:delete'; |
|
18 | + |
|
19 | + /** |
|
20 | + * The console command description. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $description = 'Delete a user.'; |
|
25 | + |
|
26 | + /** |
|
27 | + * Execute the console command. |
|
28 | + * |
|
29 | + * @return mixed |
|
30 | + */ |
|
31 | + public function fire() |
|
32 | + { |
|
33 | + $email = $this->argument('email'); |
|
34 | + |
|
35 | + try { |
|
36 | + $user = User::whereEmail($email)->firstOrFail(); |
|
37 | + $user->delete(); |
|
38 | + |
|
39 | + $this->info('User deleted.'); |
|
40 | + } catch (ModelNotFoundException $e) { |
|
41 | + $this->error('Did not find a user with the given email address'); |
|
42 | + } |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Get the console command arguments. |
|
47 | + * |
|
48 | + * @return array |
|
49 | + */ |
|
50 | + protected function getArguments() |
|
51 | + { |
|
52 | + return [ |
|
53 | + ['email', InputArgument::REQUIRED, 'The email address of the user.'], |
|
54 | + ]; |
|
55 | + } |
|
56 | 56 | } |
@@ -7,25 +7,25 @@ |
||
7 | 7 | |
8 | 8 | class Kernel extends ConsoleKernel |
9 | 9 | { |
10 | - /** |
|
11 | - * The Artisan commands provided by your application. |
|
12 | - * |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected $commands = [ |
|
16 | - 'PiFinder\Console\Commands\FlushOldDevices', |
|
17 | - 'PiFinder\Console\Commands\UserCreate', |
|
18 | - 'PiFinder\Console\Commands\UserDelete', |
|
19 | - ]; |
|
10 | + /** |
|
11 | + * The Artisan commands provided by your application. |
|
12 | + * |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected $commands = [ |
|
16 | + 'PiFinder\Console\Commands\FlushOldDevices', |
|
17 | + 'PiFinder\Console\Commands\UserCreate', |
|
18 | + 'PiFinder\Console\Commands\UserDelete', |
|
19 | + ]; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Define the application's command schedule. |
|
23 | - * |
|
24 | - * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
25 | - */ |
|
26 | - protected function schedule(Schedule $schedule) |
|
27 | - { |
|
28 | - $schedule->command('pi:flush') |
|
29 | - ->everyFiveMinutes(); |
|
30 | - } |
|
21 | + /** |
|
22 | + * Define the application's command schedule. |
|
23 | + * |
|
24 | + * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
25 | + */ |
|
26 | + protected function schedule(Schedule $schedule) |
|
27 | + { |
|
28 | + $schedule->command('pi:flush') |
|
29 | + ->everyFiveMinutes(); |
|
30 | + } |
|
31 | 31 | } |
@@ -6,19 +6,19 @@ |
||
6 | 6 | |
7 | 7 | class Device extends Model |
8 | 8 | { |
9 | - protected $fillable = ['ip', 'name', 'mac', 'public', 'group']; |
|
9 | + protected $fillable = ['ip', 'name', 'mac', 'public', 'group']; |
|
10 | 10 | |
11 | - public function scopeOnHomePage($query) |
|
12 | - { |
|
13 | - return $query->where('public', 'true') |
|
14 | - ->orWhere(function ($query) { |
|
15 | - $query->where('public', 'auto') |
|
16 | - ->whereNull('group'); |
|
17 | - }); |
|
18 | - } |
|
11 | + public function scopeOnHomePage($query) |
|
12 | + { |
|
13 | + return $query->where('public', 'true') |
|
14 | + ->orWhere(function ($query) { |
|
15 | + $query->where('public', 'auto') |
|
16 | + ->whereNull('group'); |
|
17 | + }); |
|
18 | + } |
|
19 | 19 | |
20 | - public function isPublic() |
|
21 | - { |
|
22 | - return $this->public == 'true' || ($this->public == 'auto' && $this->group === null); |
|
23 | - } |
|
20 | + public function isPublic() |
|
21 | + { |
|
22 | + return $this->public == 'true' || ($this->public == 'auto' && $this->group === null); |
|
23 | + } |
|
24 | 24 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | public function scopeOnHomePage($query) |
12 | 12 | { |
13 | 13 | return $query->where('public', 'true') |
14 | - ->orWhere(function ($query) { |
|
14 | + ->orWhere(function($query) { |
|
15 | 15 | $query->where('public', 'auto') |
16 | 16 | ->whereNull('group'); |
17 | 17 | }); |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | abstract class Event |
6 | 6 | { |
7 | - // |
|
7 | + // |
|
8 | 8 | } |
@@ -7,29 +7,29 @@ |
||
7 | 7 | |
8 | 8 | class ServerWasPoked extends Event |
9 | 9 | { |
10 | - use SerializesModels; |
|
10 | + use SerializesModels; |
|
11 | 11 | |
12 | - /** |
|
13 | - * @var Device |
|
14 | - */ |
|
15 | - protected $device; |
|
12 | + /** |
|
13 | + * @var Device |
|
14 | + */ |
|
15 | + protected $device; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Create a new event instance. |
|
19 | - * |
|
20 | - * @param Device $device |
|
21 | - */ |
|
22 | - public function __construct(Device $device) |
|
23 | - { |
|
24 | - // |
|
25 | - $this->device = $device; |
|
26 | - } |
|
17 | + /** |
|
18 | + * Create a new event instance. |
|
19 | + * |
|
20 | + * @param Device $device |
|
21 | + */ |
|
22 | + public function __construct(Device $device) |
|
23 | + { |
|
24 | + // |
|
25 | + $this->device = $device; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return Device |
|
30 | - */ |
|
31 | - public function getDevice() |
|
32 | - { |
|
33 | - return $this->device; |
|
34 | - } |
|
28 | + /** |
|
29 | + * @return Device |
|
30 | + */ |
|
31 | + public function getDevice() |
|
32 | + { |
|
33 | + return $this->device; |
|
34 | + } |
|
35 | 35 | } |
@@ -6,17 +6,17 @@ |
||
6 | 6 | |
7 | 7 | class GroupController extends Controller |
8 | 8 | { |
9 | - /** |
|
10 | - * Show all Devices for the given group. |
|
11 | - * |
|
12 | - * @param string $group |
|
13 | - * |
|
14 | - * @return Response |
|
15 | - */ |
|
16 | - public function show($group) |
|
17 | - { |
|
18 | - $devices = Device::where('group', $group)->get(); |
|
9 | + /** |
|
10 | + * Show all Devices for the given group. |
|
11 | + * |
|
12 | + * @param string $group |
|
13 | + * |
|
14 | + * @return Response |
|
15 | + */ |
|
16 | + public function show($group) |
|
17 | + { |
|
18 | + $devices = Device::where('group', $group)->get(); |
|
19 | 19 | |
20 | - return view('overview')->with(compact('devices', 'group')); |
|
21 | - } |
|
20 | + return view('overview')->with(compact('devices', 'group')); |
|
21 | + } |
|
22 | 22 | } |