PanelUpdate.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Console\Commands;
  3. use Artisan;
  4. use Exception;
  5. use Illuminate\Console\Command;
  6. class PanelUpdate extends Command
  7. {
  8. protected $signature = 'panel:update';
  9. protected $description = 'ProxyPanel Version Update (面板更新)';
  10. public function handle(): void
  11. {
  12. try {
  13. $bar = $this->output->createProgressBar(2);
  14. $bar->minSecondsBetweenRedraws(0);
  15. $this->info(' ___ ___ _ '.PHP_EOL." / _ \ _ __ ___ __ __ _ _ / _ \ __ _ _ __ ___ | |".PHP_EOL." / /_)/| '__| / _ \ \ \/ /| | | | / /_)/ / _` || '_ \ / _ \| |".PHP_EOL.'/ ___/ | | | (_) | > < | |_| |/ ___/ | (_| || | | || __/| |'.PHP_EOL."\/ |_| \___/ /_/\_\ \__, |\/ \__,_||_| |_| \___||_|".PHP_EOL.' |___/ '.PHP_EOL);
  16. $bar->start();
  17. $this->line(' 更新数据库...');
  18. Artisan::call('migrate --force');
  19. if (config('app.demo') && $this->confirm('检测到您在DEMO模式, 是否重置数据库?')) {
  20. Artisan::call('migrate:fresh --seed --force');
  21. }
  22. $bar->advance();
  23. $this->line(' 更新缓存...');
  24. Artisan::call('optimize');
  25. $bar->finish();
  26. $this->info(' 更新完毕! ');
  27. } catch (Exception $e) {
  28. $this->error($e->getMessage());
  29. }
  30. }
  31. }