| @@ 7-32 (lines=26) @@ | ||
| 4 | ||
| 5 | use Spatie\UptimeMonitor\MonitorRepository; |
|
| 6 | ||
| 7 | class DisableMonitor extends BaseCommand |
|
| 8 | { |
|
| 9 | protected $signature = 'monitor:disable {url}'; |
|
| 10 | ||
| 11 | protected $description = 'Disable a monitor'; |
|
| 12 | ||
| 13 | public function handle() |
|
| 14 | { |
|
| 15 | foreach (explode(',', $this->argument('url')) as $url) { |
|
| 16 | $this->disableMonitor(trim($url)); |
|
| 17 | } |
|
| 18 | } |
|
| 19 | ||
| 20 | protected function disableMonitor(string $url) |
|
| 21 | { |
|
| 22 | if (! $monitor = MonitorRepository::findByUrl($url)) { |
|
| 23 | $this->error("There is no monitor configured for url `{$url}`."); |
|
| 24 | ||
| 25 | return; |
|
| 26 | } |
|
| 27 | ||
| 28 | $monitor->disable(); |
|
| 29 | ||
| 30 | $this->info("The checks for url `{$url}` are now disabled."); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||
| @@ 7-32 (lines=26) @@ | ||
| 4 | ||
| 5 | use Spatie\UptimeMonitor\MonitorRepository; |
|
| 6 | ||
| 7 | class EnableMonitor extends BaseCommand |
|
| 8 | { |
|
| 9 | protected $signature = 'monitor:enable {url}'; |
|
| 10 | ||
| 11 | protected $description = 'Enable a monitor'; |
|
| 12 | ||
| 13 | public function handle() |
|
| 14 | { |
|
| 15 | foreach (explode(',', $this->argument('url')) as $url) { |
|
| 16 | $this->enableMonitor(trim($url)); |
|
| 17 | } |
|
| 18 | } |
|
| 19 | ||
| 20 | protected function enableMonitor(string $url) |
|
| 21 | { |
|
| 22 | if (! $monitor = MonitorRepository::findByUrl($url)) { |
|
| 23 | $this->error("There is no monitor configured for url `{$url}`."); |
|
| 24 | ||
| 25 | return; |
|
| 26 | } |
|
| 27 | ||
| 28 | $monitor->enable(); |
|
| 29 | ||
| 30 | $this->info("The checks for url `{$url}` are now enabled."); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||