InitSystemChannel.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Channel;
  4. use Illuminate\Console\Command;
  5. class InitSystemChannel extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'init:system.channel';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'create system channel. like pali text , wbw template ect.';
  19. protected $channels =[
  20. [
  21. "name"=>'_System_Pali_VRI_',
  22. 'type'=>'original',
  23. 'lang'=>'pali',
  24. ],
  25. [
  26. "name"=>'_System_Wbw_VRI_',
  27. 'type'=>'original',
  28. 'lang'=>'pali',
  29. ],
  30. [
  31. "name"=>'_System_Grammar_Term_zh-hans_',
  32. 'type'=>'translation',
  33. 'lang'=>'zh-Hans',
  34. ],
  35. [
  36. "name"=>'_System_Grammar_Term_zh-hant_',
  37. 'type'=>'translation',
  38. 'lang'=>'zh-Hant',
  39. ],
  40. [
  41. "name"=>'_System_Grammar_Term_en_',
  42. 'type'=>'translation',
  43. 'lang'=>'en',
  44. ],
  45. [
  46. "name"=>'_community_term_zh-hans_',
  47. 'type'=>'translation',
  48. 'lang'=>'zh-Hans',
  49. ],
  50. [
  51. "name"=>'_community_term_zh-hant_',
  52. 'type'=>'translation',
  53. 'lang'=>'zh-Hant',
  54. ],
  55. [
  56. "name"=>'_community_term_en_',
  57. 'type'=>'translation',
  58. 'lang'=>'en',
  59. ],
  60. [
  61. "name"=>'_community_translation_zh-hans_',
  62. 'type'=>'translation',
  63. 'lang'=>'zh-Hans',
  64. ],
  65. [
  66. "name"=>'_community_translation_zh-hant_',
  67. 'type'=>'translation',
  68. 'lang'=>'zh-Hant',
  69. ],
  70. [
  71. "name"=>'_community_translation_en_',
  72. 'type'=>'translation',
  73. 'lang'=>'en',
  74. ],
  75. [
  76. "name"=>'_System_Quote_',
  77. 'type'=>'original',
  78. 'lang'=>'en',
  79. ],
  80. ];
  81. /**
  82. * Create a new command instance.
  83. *
  84. * @return void
  85. */
  86. public function __construct()
  87. {
  88. parent::__construct();
  89. }
  90. /**
  91. * Execute the console command.
  92. *
  93. * @return int
  94. */
  95. public function handle()
  96. {
  97. if(\App\Tools\Tools::isStop()){
  98. return 0;
  99. }
  100. $this->info("start");
  101. foreach ($this->channels as $key => $value) {
  102. # code...
  103. $channel = Channel::firstOrNew([
  104. 'name' => $value['name'],
  105. 'owner_uid' => config("mint.admin.root_uuid"),
  106. ]);
  107. if(empty($channel->id)){
  108. $channel->id = app('snowflake')->id();
  109. }
  110. $channel->type = $value['type'];
  111. $channel->lang = $value['lang'];
  112. $channel->editor_id = 0;
  113. $channel->owner_uid = config("mint.admin.root_uuid");
  114. $channel->create_time = time()*1000;
  115. $channel->modify_time = time()*1000;
  116. $channel->save();
  117. $this->info("created". $value['name']);
  118. }
  119. return 0;
  120. }
  121. }