| @@ -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 | } | 
| @@ -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 | } | 
| @@ -7,37 +7,37 @@ | ||
| 7 | 7 | |
| 8 | 8 | class Handler extends ExceptionHandler | 
| 9 | 9 |  { | 
| 10 | - /** | |
| 11 | - * A list of the exception types that should not be reported. | |
| 12 | - * | |
| 13 | - * @var array | |
| 14 | - */ | |
| 15 | - protected $dontReport = [ | |
| 16 | - 'Symfony\Component\HttpKernel\Exception\HttpException', | |
| 17 | - ]; | |
| 10 | + /** | |
| 11 | + * A list of the exception types that should not be reported. | |
| 12 | + * | |
| 13 | + * @var array | |
| 14 | + */ | |
| 15 | + protected $dontReport = [ | |
| 16 | + 'Symfony\Component\HttpKernel\Exception\HttpException', | |
| 17 | + ]; | |
| 18 | 18 | |
| 19 | - /** | |
| 20 | - * Report or log an exception. | |
| 21 | - * | |
| 22 | - * This is a great spot to send exceptions to Sentry, Bugsnag, etc. | |
| 23 | - * | |
| 24 | - * @param \Exception $e | |
| 25 | - */ | |
| 26 | - public function report(Exception $e) | |
| 27 | -    { | |
| 28 | - return parent::report($e); | |
| 29 | - } | |
| 19 | + /** | |
| 20 | + * Report or log an exception. | |
| 21 | + * | |
| 22 | + * This is a great spot to send exceptions to Sentry, Bugsnag, etc. | |
| 23 | + * | |
| 24 | + * @param \Exception $e | |
| 25 | + */ | |
| 26 | + public function report(Exception $e) | |
| 27 | +	{ | |
| 28 | + return parent::report($e); | |
| 29 | + } | |
| 30 | 30 | |
| 31 | - /** | |
| 32 | - * Render an exception into an HTTP response. | |
| 33 | - * | |
| 34 | - * @param \Illuminate\Http\Request $request | |
| 35 | - * @param \Exception $e | |
| 36 | - * | |
| 37 | - * @return \Illuminate\Http\Response | |
| 38 | - */ | |
| 39 | - public function render($request, Exception $e) | |
| 40 | -    { | |
| 41 | - return parent::render($request, $e); | |
| 42 | - } | |
| 31 | + /** | |
| 32 | + * Render an exception into an HTTP response. | |
| 33 | + * | |
| 34 | + * @param \Illuminate\Http\Request $request | |
| 35 | + * @param \Exception $e | |
| 36 | + * | |
| 37 | + * @return \Illuminate\Http\Response | |
| 38 | + */ | |
| 39 | + public function render($request, Exception $e) | |
| 40 | +	{ | |
| 41 | + return parent::render($request, $e); | |
| 42 | + } | |
| 43 | 43 | } | 
| @@ -7,15 +7,15 @@ | ||
| 7 | 7 | |
| 8 | 8 | class UpdateStatistics | 
| 9 | 9 |  { | 
| 10 | - /** | |
| 11 | - * Handle the event. | |
| 12 | - * | |
| 13 | - * @param ServerWasPoked $event | |
| 14 | - * | |
| 15 | - * @return void | |
| 16 | - */ | |
| 17 | - public function handle(ServerWasPoked $event) | |
| 18 | -    { | |
| 19 | - Poke::create($event->getDevice()->toArray()); | |
| 20 | - } | |
| 10 | + /** | |
| 11 | + * Handle the event. | |
| 12 | + * | |
| 13 | + * @param ServerWasPoked $event | |
| 14 | + * | |
| 15 | + * @return void | |
| 16 | + */ | |
| 17 | + public function handle(ServerWasPoked $event) | |
| 18 | +	{ | |
| 19 | + Poke::create($event->getDevice()->toArray()); | |
| 20 | + } | |
| 21 | 21 | } |