VpnUpdateStatus.php 1002 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Log;
  6. class VpnUpdateStatus extends Command
  7. {
  8. protected $signature = 'vpn:update-status {status}';
  9. protected $description = 'Aggiorna lo stato della connessione VPN';
  10. public function handle()
  11. {
  12. $status = $this->argument('status');
  13. try {
  14. DB::table('vpn_status')->updateOrInsert(
  15. ['id' => 1],
  16. [
  17. 'status' => $status,
  18. 'last_update' => now(),
  19. 'updated_at' => now(),
  20. ]
  21. );
  22. Log::info("Stato VPN aggiornato: {$status}");
  23. $this->info("Stato VPN aggiornato: {$status}");
  24. } catch (\Exception $e) {
  25. Log::error("Errore aggiornamento stato VPN: " . $e->getMessage());
  26. $this->error("Errore aggiornamento stato VPN: " . $e->getMessage());
  27. }
  28. }
  29. }