ExportOffline.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. class ExportOffline extends Command
  5. {
  6. /**
  7. * The name and signature of the console command.
  8. *
  9. * @var string
  10. */
  11. protected $signature = 'export:offline';
  12. /**
  13. * The console command description.
  14. *
  15. * @var string
  16. */
  17. protected $description = 'Command description';
  18. /**
  19. * Create a new command instance.
  20. *
  21. * @return void
  22. */
  23. public function __construct()
  24. {
  25. parent::__construct();
  26. }
  27. /**
  28. * Execute the console command.
  29. *
  30. * @return int
  31. */
  32. public function handle()
  33. {
  34. //建表
  35. $this->info('create db');
  36. $this->call('export:create.db');
  37. //导出channel
  38. $this->info('channel');
  39. $this->call('export:channel');
  40. //tag
  41. $this->info('tag');
  42. $this->call('export:tag');
  43. $this->call('export:tag.map');
  44. //
  45. $this->info('pali text');
  46. $this->call('export:pali.text');
  47. //导出章节索引
  48. $this->info('chapter');
  49. $this->call('export:chapter.index');
  50. //导出译文
  51. $this->info('sentence');
  52. $this->call('export:sentence',['--type'=>'translation']);
  53. $this->call('export:sentence',['--type'=>'nissaya']);
  54. //导出原文
  55. $this->call('export:sentence',['--type'=>'original']);
  56. $this->info('zip');
  57. $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
  58. shell_exec("tar jcf ".
  59. storage_path("app/public/export/offline-".date("Y-m-d").".tar.xz")." ".
  60. $exportFile);
  61. return 0;
  62. }
  63. }