Parcourir la source

:beers: 只能用 exists() 手工判断

visuddhinanda@gmail.com il y a 3 ans
Parent
commit
d25c91e566
1 fichiers modifiés avec 9 ajouts et 3 suppressions
  1. 9 3
      app/Console/Commands/UpgradeProgressChapter.php

+ 9 - 3
app/Console/Commands/UpgradeProgressChapter.php

@@ -121,11 +121,17 @@ class UpgradeProgressChapter extends Command
                     $validator = Validator::make($attributes, $rules);
                     if ($validator->fails()) {
                         $this->error("Validator is fails");
-                        var_dump($attributes);
                         return 0;
                     }
-                    var_dump($attributes);
-                    $chapterData = ProgressChapter::firstOrNew($attributes);
+                    if(ProgressChapter::where($attributes)->exists()){
+                        $chapterData = ProgressChapter::where($attributes)->first();
+                    }else{
+                        $chapterData = new ProgressChapter;
+                        $chapterData->book = $attributes["book"];
+                        $chapterData->para = $attributes["para"];
+                        $chapterData->channel_id = $attributes["channel_id"];
+
+                    }
                     $chapterData->lang = $lang;
                     $chapterData->all_trans = $final->cp_len/$chapter_strlen;
                     $chapterData->public = $final->cp_len/$chapter_strlen;