InitSystemChannel.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. "name" => '_community_summary_zh-hans_',
  87. 'type' => 'translation',
  88. 'lang' => 'zh-Hans',
  89. ],
  90. [
  91. "name" => '_System_commentary_',
  92. 'type' => 'commentary',
  93. 'lang' => 'en',
  94. 'status' => 30,
  95. ],
  96. ];
  97. /**
  98. * Create a new command instance.
  99. *
  100. * @return void
  101. */
  102. public function __construct()
  103. {
  104. parent::__construct();
  105. }
  106. /**
  107. * Execute the console command.
  108. *
  109. * @return int
  110. */
  111. public function handle()
  112. {
  113. if (\App\Tools\Tools::isStop()) {
  114. return 0;
  115. }
  116. $this->info("start");
  117. foreach ($this->channels as $key => $value) {
  118. # code...
  119. $channel = Channel::firstOrNew([
  120. 'name' => $value['name'],
  121. 'owner_uid' => config("mint.admin.root_uuid"),
  122. ]);
  123. if (empty($channel->id)) {
  124. $channel->id = app('snowflake')->id();
  125. }
  126. $channel->type = $value['type'];
  127. $channel->lang = $value['lang'];
  128. $channel->editor_id = 0;
  129. $channel->owner_uid = config("mint.admin.root_uuid");
  130. $channel->create_time = time() * 1000;
  131. $channel->modify_time = time() * 1000;
  132. $channel->is_system = true;
  133. if (isset($value['status'])) {
  134. $channel->status = $value['status'];
  135. }
  136. $channel->save();
  137. $this->info("created" . $value['name']);
  138. }
  139. return 0;
  140. }
  141. }