@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | class User extends Authenticatable |
9 | 9 | { |
10 | - use Notifiable; |
|
10 | + use Notifiable; |
|
11 | 11 | |
12 | - /** |
|
13 | - * The attributes that are mass assignable. |
|
14 | - * |
|
15 | - * @var array |
|
16 | - */ |
|
17 | - protected $fillable = [ |
|
18 | - 'name', 'email', 'password', |
|
19 | - ]; |
|
12 | + /** |
|
13 | + * The attributes that are mass assignable. |
|
14 | + * |
|
15 | + * @var array |
|
16 | + */ |
|
17 | + protected $fillable = [ |
|
18 | + 'name', 'email', 'password', |
|
19 | + ]; |
|
20 | 20 | |
21 | - /** |
|
22 | - * The attributes that should be hidden for arrays. |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected $hidden = [ |
|
27 | - 'password', 'remember_token', |
|
28 | - ]; |
|
21 | + /** |
|
22 | + * The attributes that should be hidden for arrays. |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected $hidden = [ |
|
27 | + 'password', 'remember_token', |
|
28 | + ]; |
|
29 | 29 | } |
@@ -8,35 +8,35 @@ |
||
8 | 8 | |
9 | 9 | class Registrar |
10 | 10 | { |
11 | - use RegistersUsers; |
|
11 | + use RegistersUsers; |
|
12 | 12 | |
13 | - /** |
|
14 | - * Get a validator for an incoming registration request. |
|
15 | - * |
|
16 | - * @param array $data |
|
17 | - * |
|
18 | - * @return \Illuminate\Contracts\Validation\Validator |
|
19 | - */ |
|
20 | - public function validator(array $data) |
|
21 | - { |
|
22 | - return Validator::make($data, [ |
|
23 | - 'email' => 'required|email|max:255|unique:users', |
|
24 | - 'password' => 'required|confirmed|min:6', |
|
25 | - ]); |
|
26 | - } |
|
13 | + /** |
|
14 | + * Get a validator for an incoming registration request. |
|
15 | + * |
|
16 | + * @param array $data |
|
17 | + * |
|
18 | + * @return \Illuminate\Contracts\Validation\Validator |
|
19 | + */ |
|
20 | + public function validator(array $data) |
|
21 | + { |
|
22 | + return Validator::make($data, [ |
|
23 | + 'email' => 'required|email|max:255|unique:users', |
|
24 | + 'password' => 'required|confirmed|min:6', |
|
25 | + ]); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Create a new user instance after a valid registration. |
|
30 | - * |
|
31 | - * @param array $data |
|
32 | - * |
|
33 | - * @return User |
|
34 | - */ |
|
35 | - public function create(array $data) |
|
36 | - { |
|
37 | - return User::create([ |
|
38 | - 'email' => $data['email'], |
|
39 | - 'password' => bcrypt($data['password']), |
|
40 | - ]); |
|
41 | - } |
|
28 | + /** |
|
29 | + * Create a new user instance after a valid registration. |
|
30 | + * |
|
31 | + * @param array $data |
|
32 | + * |
|
33 | + * @return User |
|
34 | + */ |
|
35 | + public function create(array $data) |
|
36 | + { |
|
37 | + return User::create([ |
|
38 | + 'email' => $data['email'], |
|
39 | + 'password' => bcrypt($data['password']), |
|
40 | + ]); |
|
41 | + } |
|
42 | 42 | } |
@@ -7,32 +7,32 @@ |
||
7 | 7 | |
8 | 8 | class DeviceObserver |
9 | 9 | { |
10 | - /** |
|
11 | - * @var PusherManager |
|
12 | - */ |
|
13 | - protected $pusher; |
|
10 | + /** |
|
11 | + * @var PusherManager |
|
12 | + */ |
|
13 | + protected $pusher; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @var DeviceTransformer |
|
17 | - */ |
|
18 | - private $transformer; |
|
15 | + /** |
|
16 | + * @var DeviceTransformer |
|
17 | + */ |
|
18 | + private $transformer; |
|
19 | 19 | |
20 | - /** |
|
21 | - * DeviceObserver constructor. |
|
22 | - * |
|
23 | - * @param PusherManager $pusher |
|
24 | - * @param DeviceTransformer $transformer |
|
25 | - */ |
|
26 | - public function __construct(PusherManager $pusher, DeviceTransformer $transformer) |
|
27 | - { |
|
28 | - $this->pusher = $pusher; |
|
29 | - $this->transformer = $transformer; |
|
30 | - } |
|
20 | + /** |
|
21 | + * DeviceObserver constructor. |
|
22 | + * |
|
23 | + * @param PusherManager $pusher |
|
24 | + * @param DeviceTransformer $transformer |
|
25 | + */ |
|
26 | + public function __construct(PusherManager $pusher, DeviceTransformer $transformer) |
|
27 | + { |
|
28 | + $this->pusher = $pusher; |
|
29 | + $this->transformer = $transformer; |
|
30 | + } |
|
31 | 31 | |
32 | - public function deleted($device) |
|
33 | - { |
|
34 | - $this->pusher->trigger(config('services.pusher.channel'), 'DeviceWasDeleted', [ |
|
35 | - 'device' => $this->transformer->transform($device), |
|
36 | - ]); |
|
37 | - } |
|
32 | + public function deleted($device) |
|
33 | + { |
|
34 | + $this->pusher->trigger(config('services.pusher.channel'), 'DeviceWasDeleted', [ |
|
35 | + 'device' => $this->transformer->transform($device), |
|
36 | + ]); |
|
37 | + } |
|
38 | 38 | } |
@@ -8,52 +8,52 @@ |
||
8 | 8 | |
9 | 9 | class NotifyUsersAboutPoke |
10 | 10 | { |
11 | - /** |
|
12 | - * The Pusher instance. |
|
13 | - * |
|
14 | - * @var PusherManager |
|
15 | - */ |
|
16 | - protected $pusher; |
|
17 | - |
|
18 | - /** |
|
19 | - * @var DeviceTransformer |
|
20 | - */ |
|
21 | - private $transformer; |
|
22 | - |
|
23 | - /** |
|
24 | - * Create the event handler. |
|
25 | - * |
|
26 | - * @param PusherManager $pusher |
|
27 | - * @param DeviceTransformer $transformer |
|
28 | - */ |
|
29 | - public function __construct(PusherManager $pusher, DeviceTransformer $transformer) |
|
30 | - { |
|
31 | - $this->pusher = $pusher; |
|
32 | - $this->transformer = $transformer; |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * Handle the server was poked event. |
|
37 | - * |
|
38 | - * @param ServerWasPoked $event |
|
39 | - * |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function handle(ServerWasPoked $event) |
|
43 | - { |
|
44 | - $channel = config('services.pusher.channel'); |
|
45 | - $device = $event->getDevice(); |
|
46 | - |
|
47 | - if ($device->isPublic()) { |
|
48 | - $this->pusher->trigger($channel, 'ServerWasPoked', [ |
|
49 | - 'device' => $this->transformer->transform($device), |
|
50 | - ]); |
|
51 | - } else { |
|
52 | - $channel = $channel.'-'.$device->group; |
|
53 | - |
|
54 | - $this->pusher->trigger($channel, 'ServerWasPoked', [ |
|
55 | - 'device' => $this->transformer->transform($device), |
|
56 | - ]); |
|
57 | - } |
|
58 | - } |
|
11 | + /** |
|
12 | + * The Pusher instance. |
|
13 | + * |
|
14 | + * @var PusherManager |
|
15 | + */ |
|
16 | + protected $pusher; |
|
17 | + |
|
18 | + /** |
|
19 | + * @var DeviceTransformer |
|
20 | + */ |
|
21 | + private $transformer; |
|
22 | + |
|
23 | + /** |
|
24 | + * Create the event handler. |
|
25 | + * |
|
26 | + * @param PusherManager $pusher |
|
27 | + * @param DeviceTransformer $transformer |
|
28 | + */ |
|
29 | + public function __construct(PusherManager $pusher, DeviceTransformer $transformer) |
|
30 | + { |
|
31 | + $this->pusher = $pusher; |
|
32 | + $this->transformer = $transformer; |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * Handle the server was poked event. |
|
37 | + * |
|
38 | + * @param ServerWasPoked $event |
|
39 | + * |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function handle(ServerWasPoked $event) |
|
43 | + { |
|
44 | + $channel = config('services.pusher.channel'); |
|
45 | + $device = $event->getDevice(); |
|
46 | + |
|
47 | + if ($device->isPublic()) { |
|
48 | + $this->pusher->trigger($channel, 'ServerWasPoked', [ |
|
49 | + 'device' => $this->transformer->transform($device), |
|
50 | + ]); |
|
51 | + } else { |
|
52 | + $channel = $channel.'-'.$device->group; |
|
53 | + |
|
54 | + $this->pusher->trigger($channel, 'ServerWasPoked', [ |
|
55 | + 'device' => $this->transformer->transform($device), |
|
56 | + ]); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class DeviceArchive extends Model |
8 | 8 | { |
9 | - protected $table = 'device_archive'; |
|
9 | + protected $table = 'device_archive'; |
|
10 | 10 | |
11 | - protected $guarded = []; |
|
11 | + protected $guarded = []; |
|
12 | 12 | } |
@@ -11,29 +11,29 @@ |
||
11 | 11 | |
12 | 12 | class UpdateStatistics |
13 | 13 | { |
14 | - /** |
|
15 | - * Handle the event. |
|
16 | - * |
|
17 | - * @param ServerWasPoked $event |
|
18 | - * |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function handle(ServerWasPoked $event) |
|
22 | - { |
|
23 | - $device = $event->getDevice()->toArray(); |
|
14 | + /** |
|
15 | + * Handle the event. |
|
16 | + * |
|
17 | + * @param ServerWasPoked $event |
|
18 | + * |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function handle(ServerWasPoked $event) |
|
22 | + { |
|
23 | + $device = $event->getDevice()->toArray(); |
|
24 | 24 | |
25 | - // device count |
|
26 | - DeviceArchive::updateOrCreate( |
|
27 | - ['mac_hash' => md5($device['mac'])], |
|
28 | - ['updated_at' => Carbon::now()] |
|
29 | - ); |
|
25 | + // device count |
|
26 | + DeviceArchive::updateOrCreate( |
|
27 | + ['mac_hash' => md5($device['mac'])], |
|
28 | + ['updated_at' => Carbon::now()] |
|
29 | + ); |
|
30 | 30 | |
31 | - // network distribution |
|
32 | - $network = ExtractNetwork::fromIp($device['ip']); |
|
33 | - DB::table('network_distribution')->where('network', $network)->increment('pokes'); |
|
31 | + // network distribution |
|
32 | + $network = ExtractNetwork::fromIp($device['ip']); |
|
33 | + DB::table('network_distribution')->where('network', $network)->increment('pokes'); |
|
34 | 34 | |
35 | - // pokes |
|
36 | - $date = Carbon::now()->toDateString(); |
|
37 | - Poke::firstOrCreate(['date' => $date])->increment('pokes'); |
|
38 | - } |
|
35 | + // pokes |
|
36 | + $date = Carbon::now()->toDateString(); |
|
37 | + Poke::firstOrCreate(['date' => $date])->increment('pokes'); |
|
38 | + } |
|
39 | 39 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class Poke extends Model |
8 | 8 | { |
9 | - protected $guarded = []; |
|
9 | + protected $guarded = []; |
|
10 | 10 | |
11 | - public $timestamps = false; |
|
11 | + public $timestamps = false; |
|
12 | 12 | } |
@@ -4,27 +4,27 @@ |
||
4 | 4 | |
5 | 5 | class ExtractNetwork |
6 | 6 | { |
7 | - /** |
|
8 | - * Extract the network from the ip address. |
|
9 | - * |
|
10 | - * @param string $ip |
|
11 | - * |
|
12 | - * @return string $network |
|
13 | - */ |
|
14 | - public static function fromIp($ip) |
|
15 | - { |
|
16 | - if (starts_with($ip, '192.168.')) { |
|
17 | - return '192.168.0.0/16'; |
|
18 | - } |
|
7 | + /** |
|
8 | + * Extract the network from the ip address. |
|
9 | + * |
|
10 | + * @param string $ip |
|
11 | + * |
|
12 | + * @return string $network |
|
13 | + */ |
|
14 | + public static function fromIp($ip) |
|
15 | + { |
|
16 | + if (starts_with($ip, '192.168.')) { |
|
17 | + return '192.168.0.0/16'; |
|
18 | + } |
|
19 | 19 | |
20 | - if (starts_with($ip, '10.')) { |
|
21 | - return '10.0.0.0/8'; |
|
22 | - } |
|
20 | + if (starts_with($ip, '10.')) { |
|
21 | + return '10.0.0.0/8'; |
|
22 | + } |
|
23 | 23 | |
24 | - if (preg_match('/^172\.(1[6-9]|2[0-9]|3[01])\./', $ip)) { |
|
25 | - return '172.16.0.0/12'; |
|
26 | - } |
|
24 | + if (preg_match('/^172\.(1[6-9]|2[0-9]|3[01])\./', $ip)) { |
|
25 | + return '172.16.0.0/12'; |
|
26 | + } |
|
27 | 27 | |
28 | - return 'Internet'; |
|
29 | - } |
|
28 | + return 'Internet'; |
|
29 | + } |
|
30 | 30 | } |
@@ -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 | } |
@@ -53,11 +53,11 @@ |
||
53 | 53 | $password = $this->option('password'); |
54 | 54 | $password_confirmation = $this->option('password_confirmation'); |
55 | 55 | |
56 | - if (! $password) { |
|
56 | + if (!$password) { |
|
57 | 57 | $password = $this->secret('What password should the user have?'); |
58 | 58 | } |
59 | 59 | |
60 | - if (! $password_confirmation) { |
|
60 | + if (!$password_confirmation) { |
|
61 | 61 | $password_confirmation = $this->secret('Please confirm the password.'); |
62 | 62 | } |
63 | 63 |