InitSystemChannel.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /**
  32. * Create a new command instance.
  33. *
  34. * @return void
  35. */
  36. public function __construct()
  37. {
  38. parent::__construct();
  39. }
  40. /**
  41. * Execute the console command.
  42. *
  43. * @return int
  44. */
  45. public function handle()
  46. {
  47. $this->info("start");
  48. foreach ($this->channels as $key => $value) {
  49. # code...
  50. $channel = Channel::firstOrNew([
  51. 'name' => $value['name'],
  52. 'owner_uid' => config("app.admin.root_uuid"),
  53. ]);
  54. if(empty($channel->id)){
  55. $channel->id = app('snowflake')->id();
  56. }
  57. $channel->type = $value['type'];
  58. $channel->lang = $value['lang'];
  59. $channel->editor_id = 0;
  60. $channel->owner_uid = config("app.admin.root_uuid");
  61. $channel->create_time = time()*1000;
  62. $channel->modify_time = time()*1000;
  63. $channel->save();
  64. $this->info("created". $value['name']);
  65. }
  66. return 0;
  67. }
  68. }