ソースを参照

content 渲染为 unity 格式

visuddhinanda 2 年 前
コミット
88f24aa5a8
1 ファイル変更23 行追加9 行削除
  1. 23 9
      app/Console/Commands/ExportSentence.php

+ 23 - 9
app/Console/Commands/ExportSentence.php

@@ -8,6 +8,8 @@ use App\Models\Sentence;
 use App\Models\Channel;
 use App\Http\Api\ChannelApi;
 use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Str;
+use App\Http\Api\MdRender;
 
 class ExportSentence extends Command
 {
@@ -94,15 +96,27 @@ class ExportSentence extends Command
                                 'content','content_type','channel_uid',
                                 'editor_uid','language','updated_at'])->cursor();
         foreach ($srcDb as $sent) {
-            $currData = array(
-                    $sent->book_id,
-                    $sent->paragraph,
-                    $sent->word_start,
-                    $sent->word_end,
-                    $sent->content,
-                    $sent->channel_uid,
-                );
-            $stmt->execute($currData);
+            if(Str::isUuid($sent->channel_uid)){
+                Log::info('sent id'.$sent->uid);
+                $channel = ChannelApi::getById($sent->channel_uid);
+                $currData = array(
+                        $sent->book_id,
+                        $sent->paragraph,
+                        $sent->word_start,
+                        $sent->word_end,
+                        MdRender::render($sent->content,
+                                        [$sent->channel_uid],
+                                        null,
+                                        'read',
+                                        $channel['type'],
+                                        $sent->content_type,
+                                        'unity',
+                                        ),
+                        $sent->channel_uid,
+                    );
+                $stmt->execute($currData);
+
+            }
             $bar->advance();
         }
         $dbh->commit();