@@ -6,51 +6,51 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Kernel extends HttpKernel |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * The application's global HTTP middleware stack. |
|
| 11 | - * |
|
| 12 | - * These middleware are run during every request to your application. |
|
| 13 | - * |
|
| 14 | - * @var array |
|
| 15 | - */ |
|
| 16 | - protected $middleware = [ |
|
| 17 | - \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, |
|
| 18 | - ]; |
|
| 9 | + /** |
|
| 10 | + * The application's global HTTP middleware stack. |
|
| 11 | + * |
|
| 12 | + * These middleware are run during every request to your application. |
|
| 13 | + * |
|
| 14 | + * @var array |
|
| 15 | + */ |
|
| 16 | + protected $middleware = [ |
|
| 17 | + \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, |
|
| 18 | + ]; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * The application's route middleware groups. |
|
| 22 | - * |
|
| 23 | - * @var array |
|
| 24 | - */ |
|
| 25 | - protected $middlewareGroups = [ |
|
| 26 | - 'web' => [ |
|
| 27 | - \PiFinder\Http\Middleware\EncryptCookies::class, |
|
| 28 | - \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
|
| 29 | - \Illuminate\Session\Middleware\StartSession::class, |
|
| 30 | - \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|
| 31 | - \PiFinder\Http\Middleware\VerifyCsrfToken::class, |
|
| 32 | - \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
| 33 | - ], |
|
| 20 | + /** |
|
| 21 | + * The application's route middleware groups. |
|
| 22 | + * |
|
| 23 | + * @var array |
|
| 24 | + */ |
|
| 25 | + protected $middlewareGroups = [ |
|
| 26 | + 'web' => [ |
|
| 27 | + \PiFinder\Http\Middleware\EncryptCookies::class, |
|
| 28 | + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
|
| 29 | + \Illuminate\Session\Middleware\StartSession::class, |
|
| 30 | + \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|
| 31 | + \PiFinder\Http\Middleware\VerifyCsrfToken::class, |
|
| 32 | + \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
| 33 | + ], |
|
| 34 | 34 | |
| 35 | - 'api' => [ |
|
| 36 | - 'throttle:60,1', |
|
| 37 | - 'bindings', |
|
| 38 | - ], |
|
| 39 | - ]; |
|
| 35 | + 'api' => [ |
|
| 36 | + 'throttle:60,1', |
|
| 37 | + 'bindings', |
|
| 38 | + ], |
|
| 39 | + ]; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * The application's route middleware. |
|
| 43 | - * |
|
| 44 | - * These middleware may be assigned to groups or used individually. |
|
| 45 | - * |
|
| 46 | - * @var array |
|
| 47 | - */ |
|
| 48 | - protected $routeMiddleware = [ |
|
| 49 | - 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, |
|
| 50 | - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
|
| 51 | - 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
| 52 | - 'can' => \Illuminate\Auth\Middleware\Authorize::class, |
|
| 53 | - 'guest' => \PiFinder\Http\Middleware\RedirectIfAuthenticated::class, |
|
| 54 | - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|
| 55 | - ]; |
|
| 41 | + /** |
|
| 42 | + * The application's route middleware. |
|
| 43 | + * |
|
| 44 | + * These middleware may be assigned to groups or used individually. |
|
| 45 | + * |
|
| 46 | + * @var array |
|
| 47 | + */ |
|
| 48 | + protected $routeMiddleware = [ |
|
| 49 | + 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, |
|
| 50 | + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
|
| 51 | + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
| 52 | + 'can' => \Illuminate\Auth\Middleware\Authorize::class, |
|
| 53 | + 'guest' => \PiFinder\Http\Middleware\RedirectIfAuthenticated::class, |
|
| 54 | + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|
| 55 | + ]; |
|
| 56 | 56 | } |
@@ -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 | } |
@@ -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 | } |