PanelUpdate.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'panel:update';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'ProxyPanel Version Update (面板更新)';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return mixed
  33. */
  34. public function handle()
  35. {
  36. try {
  37. $bar = $this->output->createProgressBar(2);
  38. $bar->minSecondsBetweenRedraws(0);
  39. $this->info(' ___ ___ _ '.PHP_EOL." / _ \ _ __ ___ __ __ _ _ / _ \ __ _ _ __ ___ | |".PHP_EOL." / /_)/| '__| / _ \ \ \/ /| | | | / /_)/ / _` || '_ \ / _ \| |".PHP_EOL.'/ ___/ | | | (_) | > < | |_| |/ ___/ | (_| || | | || __/| |'.PHP_EOL."\/ |_| \___/ /_/\_\ \__, |\/ \__,_||_| |_| \___||_|".PHP_EOL.' |___/ '.PHP_EOL);
  40. $bar->start();
  41. $this->line(' 更新数据库...');
  42. Artisan::call('migrate --force');
  43. if (config('app.demo') && $this->confirm('检测到您在DEMO模式, 是否重置数据库?')) {
  44. Artisan::call('migrate:fresh --seed');
  45. }
  46. $bar->advance();
  47. $this->line(' 更新缓存...');
  48. Artisan::call('optimize');
  49. $bar->finish();
  50. $this->info(' 更新完毕! ');
  51. } catch (Exception $e) {
  52. $this->error($e->getMessage());
  53. }
  54. return 0;
  55. }
  56. }