@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | abstract class Command |
6 | 6 | { |
7 | - // |
|
7 | + // |
|
8 | 8 | } |
@@ -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,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 | } |
@@ -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 | } |
@@ -7,41 +7,41 @@ |
||
7 | 7 | |
8 | 8 | class Authenticate |
9 | 9 | { |
10 | - /** |
|
11 | - * The Guard implementation. |
|
12 | - * |
|
13 | - * @var Guard |
|
14 | - */ |
|
15 | - protected $auth; |
|
10 | + /** |
|
11 | + * The Guard implementation. |
|
12 | + * |
|
13 | + * @var Guard |
|
14 | + */ |
|
15 | + protected $auth; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Create a new filter instance. |
|
19 | - * |
|
20 | - * @param Guard $auth |
|
21 | - */ |
|
22 | - public function __construct(Guard $auth) |
|
23 | - { |
|
24 | - $this->auth = $auth; |
|
25 | - } |
|
17 | + /** |
|
18 | + * Create a new filter instance. |
|
19 | + * |
|
20 | + * @param Guard $auth |
|
21 | + */ |
|
22 | + public function __construct(Guard $auth) |
|
23 | + { |
|
24 | + $this->auth = $auth; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Handle an incoming request. |
|
29 | - * |
|
30 | - * @param \Illuminate\Http\Request $request |
|
31 | - * @param \Closure $next |
|
32 | - * |
|
33 | - * @return mixed |
|
34 | - */ |
|
35 | - public function handle($request, Closure $next) |
|
36 | - { |
|
37 | - if ($this->auth->guest()) { |
|
38 | - if ($request->ajax()) { |
|
39 | - return response('Unauthorized.', 401); |
|
40 | - } else { |
|
41 | - return redirect()->guest('auth/login'); |
|
42 | - } |
|
43 | - } |
|
27 | + /** |
|
28 | + * Handle an incoming request. |
|
29 | + * |
|
30 | + * @param \Illuminate\Http\Request $request |
|
31 | + * @param \Closure $next |
|
32 | + * |
|
33 | + * @return mixed |
|
34 | + */ |
|
35 | + public function handle($request, Closure $next) |
|
36 | + { |
|
37 | + if ($this->auth->guest()) { |
|
38 | + if ($request->ajax()) { |
|
39 | + return response('Unauthorized.', 401); |
|
40 | + } else { |
|
41 | + return redirect()->guest('auth/login'); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | - return $next($request); |
|
46 | - } |
|
45 | + return $next($request); |
|
46 | + } |
|
47 | 47 | } |
@@ -8,37 +8,37 @@ |
||
8 | 8 | |
9 | 9 | class RedirectIfAuthenticated |
10 | 10 | { |
11 | - /** |
|
12 | - * The Guard implementation. |
|
13 | - * |
|
14 | - * @var Guard |
|
15 | - */ |
|
16 | - protected $auth; |
|
11 | + /** |
|
12 | + * The Guard implementation. |
|
13 | + * |
|
14 | + * @var Guard |
|
15 | + */ |
|
16 | + protected $auth; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Create a new filter instance. |
|
20 | - * |
|
21 | - * @param Guard $auth |
|
22 | - */ |
|
23 | - public function __construct(Guard $auth) |
|
24 | - { |
|
25 | - $this->auth = $auth; |
|
26 | - } |
|
18 | + /** |
|
19 | + * Create a new filter instance. |
|
20 | + * |
|
21 | + * @param Guard $auth |
|
22 | + */ |
|
23 | + public function __construct(Guard $auth) |
|
24 | + { |
|
25 | + $this->auth = $auth; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Handle an incoming request. |
|
30 | - * |
|
31 | - * @param \Illuminate\Http\Request $request |
|
32 | - * @param \Closure $next |
|
33 | - * |
|
34 | - * @return mixed |
|
35 | - */ |
|
36 | - public function handle($request, Closure $next) |
|
37 | - { |
|
38 | - if ($this->auth->check()) { |
|
39 | - return new RedirectResponse(url('/home')); |
|
40 | - } |
|
28 | + /** |
|
29 | + * Handle an incoming request. |
|
30 | + * |
|
31 | + * @param \Illuminate\Http\Request $request |
|
32 | + * @param \Closure $next |
|
33 | + * |
|
34 | + * @return mixed |
|
35 | + */ |
|
36 | + public function handle($request, Closure $next) |
|
37 | + { |
|
38 | + if ($this->auth->check()) { |
|
39 | + return new RedirectResponse(url('/home')); |
|
40 | + } |
|
41 | 41 | |
42 | - return $next($request); |
|
43 | - } |
|
42 | + return $next($request); |
|
43 | + } |
|
44 | 44 | } |