]> _ Git - cubist_cms-back.git/commitdiff
wip #3262
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 13 Dec 2019 17:22:20 +0000 (18:22 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 13 Dec 2019 17:22:20 +0000 (18:22 +0100)
src/app/Console/Commands/LocaleSlugReset.php

index 31cb732e446b8504f96d2a6a206c26dfec423fd1..994e0499311516688841cf56947a4f618093bb9d 100644 (file)
@@ -4,6 +4,7 @@ namespace Cubist\Backpack\app\Console\Commands;
 
 use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel;
 use Cubist\Backpack\app\Magic\Models\CubistMagicTranslatableModel;
+use Cubist\Backpack\app\Magic\Models\Locale;
 
 class LocaleSlugReset extends CubistCommand
 {
@@ -39,6 +40,7 @@ class LocaleSlugReset extends CubistCommand
         $class = get_class($model);
         $all = $class::all();
         $locale = $this->argument('locale');
+        $default = Locale::getDefaultLocale();
         foreach ($all as $instance) {
             $instance->setLocale($locale);
             /** @var CubistMagicTranslatableModel $instance */
@@ -57,15 +59,15 @@ class LocaleSlugReset extends CubistCommand
             }
 
             if (!$reset) {
-                echo 'skip ' . $translations[$locale] . "\n";
+               // echo 'skip ' . $translations[$locale] . "\n";
                 continue;
             }
 
             $new = $instance->getSlugOrTitleAttribute(true);
             if (!$new) {
-                continue;
+                $new = $translations[$default];
             }
-            echo 'reset "' . $translations[$locale] . '" -> ' . $new . "\n";
+            //echo 'reset "' . $translations[$locale] . '" -> ' . $new . "\n";
             $instance->setTranslation('slug', $locale, $new);
             $instance->save();
         }