2
0

InitSystemChannel.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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"=>'_System_Grammar_Term_my_',
  47. 'type'=>'translation',
  48. 'lang'=>'my',
  49. ],
  50. [
  51. "name"=>'_community_term_zh-hans_',
  52. 'type'=>'translation',
  53. 'lang'=>'zh-Hans',
  54. ],
  55. [
  56. "name"=>'_community_term_zh-hant_',
  57. 'type'=>'translation',
  58. 'lang'=>'zh-Hant',
  59. ],
  60. [
  61. "name"=>'_community_term_en_',
  62. 'type'=>'translation',
  63. 'lang'=>'en',
  64. ],
  65. [
  66. "name"=>'_community_translation_zh-hans_',
  67. 'type'=>'translation',
  68. 'lang'=>'zh-Hans',
  69. ],
  70. [
  71. "name"=>'_community_translation_zh-hant_',
  72. 'type'=>'translation',
  73. 'lang'=>'zh-Hant',
  74. ],
  75. [
  76. "name"=>'_community_translation_en_',
  77. 'type'=>'translation',
  78. 'lang'=>'en',
  79. ],
  80. [
  81. "name"=>'_System_Quote_',
  82. 'type'=>'original',
  83. 'lang'=>'en',
  84. ],
  85. ];
  86. /**
  87. * Create a new command instance.
  88. *
  89. * @return void
  90. */
  91. public function __construct()
  92. {
  93. parent::__construct();
  94. }
  95. /**
  96. * Execute the console command.
  97. *
  98. * @return int
  99. */
  100. public function handle()
  101. {
  102. if(\App\Tools\Tools::isStop()){
  103. return 0;
  104. }
  105. $this->info("start");
  106. foreach ($this->channels as $key => $value) {
  107. # code...
  108. $channel = Channel::firstOrNew([
  109. 'name' => $value['name'],
  110. 'owner_uid' => config("mint.admin.root_uuid"),
  111. ]);
  112. if(empty($channel->id)){
  113. $channel->id = app('snowflake')->id();
  114. }
  115. $channel->type = $value['type'];
  116. $channel->lang = $value['lang'];
  117. $channel->editor_id = 0;
  118. $channel->owner_uid = config("mint.admin.root_uuid");
  119. $channel->create_time = time()*1000;
  120. $channel->modify_time = time()*1000;
  121. $channel->is_system = true;
  122. $channel->save();
  123. $this->info("created". $value['name']);
  124. }
  125. return 0;
  126. }
  127. }