Browse Source

:bug: createOrUpdate 改为 fristOrNew

visuddhinanda 3 năm trước cách đây
mục cha
commit
ab3571e447

+ 9 - 7
app/Console/Commands/InitCs6sentence.php

@@ -132,15 +132,17 @@ class InitCs6sentence extends Command
 				[
 					'id' =>$snowId,
 					'uid' =>Str::uuid(),
-					'editor_uid'=>config("app.admin.root_uuid"),
-					'content'=>trim($sent),
-					'strlen'=>mb_strlen($sent,"UTF-8"),
-					'status' => 30,
-					'create_time'=>time()*1000,
-					'modify_time'=>time()*1000,
-					'language'=>'en'
 				]
 				);
+            $newRow->editor_uid = config("app.admin.root_uuid");
+            $newRow->content = trim($sent);
+            $newRow->strlen = mb_strlen($sent,"UTF-8");
+            $newRow->status = 30;
+            $newRow->create_time = time()*1000;
+            $newRow->modify_time = time()*1000;
+            $newRow->language = 'en';
+            $newRow->save();
+
 			$bar->advance();
 		}
 		$bar->finish();

+ 10 - 8
app/Console/Commands/UpgradeWbwTemplate.php

@@ -88,7 +88,7 @@ class UpgradeWbwTemplate extends Command
             }
             $sent = \json_encode($wbwContent);
 
-			$newRow = Sentence::updateOrCreate(
+			$newRow = Sentence::firstOrNew(
 				[
 					"book_id" => $value->book,
 					"paragraph" => $value->paragraph,
@@ -99,15 +99,17 @@ class UpgradeWbwTemplate extends Command
 				[
 					'id' =>app('snowflake')->id(),
 					'uid' =>Str::uuid(),
-					'editor_uid'=>config("app.admin.root_uuid"),
-					'content'=>trim($sent),
-					'strlen'=>mb_strlen($sent,"UTF-8"),
-					'status' => 30,
-					'create_time'=>time()*1000,
-					'modify_time'=>time()*1000,
-					'language'=>'en'
 				]
 				);
+            $newRow->editor_uid = config("app.admin.root_uuid");
+            $newRow->content = trim($sent);
+            $newRow->strlen = mb_strlen($sent,"UTF-8");
+            $newRow->status = 30;
+            $newRow->create_time = time()*1000;
+            $newRow->modify_time = time()*1000;
+            $newRow->language = 'en';
+            $newRow->save();
+
 			$bar->advance();
 		}
 		$bar->finish();