Prechádzať zdrojové kódy

:construction: create 把wbw模版刷到句子库

visuddhinanda 3 rokov pred
rodič
commit
6c4d8a6021
1 zmenil súbory, kde vykonal 75 pridanie a 0 odobranie
  1. 75 0
      app/Console/Commands/InitSystemChannel.php

+ 75 - 0
app/Console/Commands/InitSystemChannel.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\Channel;
+use Illuminate\Console\Command;
+
+class InitSystemChannel extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'init:system.channel';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'create system channel. like pali text , wbw template ect.';
+
+    protected $channels =[
+        [
+            "name"=>'_System_Pali_VRI_',
+            'type'=>'original',
+            'lang'=>'pali',
+        ],
+        [
+            "name"=>'_System_Wbw_VRI_',
+            'type'=>'original',
+            'lang'=>'pali',
+        ],
+    ];
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        $this->info("start");
+        foreach ($this->channels as $key => $value) {
+            # code...
+            $channel = Channel::firstOrNew([
+                'name' => $value['name'],
+                'owner_uid' => config("app.admin.root_uuid"),
+            ]);
+            if(empty($channel->id)){
+                $channel->id = app('snowflake')->id();
+            }
+            $channel->type = $value['type'];
+            $channel->lang = $value['lang'];
+            $channel->editor_id = 0;
+            $channel->owner_uid = config("app.admin.root_uuid");
+            $channel->create_time = time()*1000;
+            $channel->modify_time = time()*1000;
+            $channel->save();
+            $this->info("created". $value['name']);
+        }
+        return 0;
+    }
+}