]> _ Git - fluidbook-toolbox.git/commitdiff
wip #3753 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Nov 2020 15:31:48 +0000 (16:31 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Nov 2020 15:31:48 +0000 (16:31 +0100)
app/Console/Commands/WorkshopMigration.php
app/Models/FluidbookQuote.php

index 9e16e00bede651322fcd9243abc4e4e8627c358b..1256ce80c77f2093debbc161628ff6fc23608cdc 100644 (file)
@@ -3,6 +3,7 @@
 
 namespace App\Console\Commands;
 
+use App\Models\FluidbookQuote;
 use App\Models\Signature;
 use Cubist\Backpack\app\Console\Commands\CubistCommand;
 use Illuminate\Support\Facades\DB;
@@ -18,7 +19,7 @@ class WorkshopMigration extends CubistCommand
     {
         $actions = [
             'Backup current database' => 'backup',
-            'Import Signatures' => 'importSignatures',
+            'Import Quotes' => 'importQuotes',
             'Migrate magic models' => 'migrate',
             'Clean caches' => 'cleanCache'
         ];
@@ -55,26 +56,52 @@ class WorkshopMigration extends CubistCommand
         $this->executeProcessQuiet('php artisan optimize:clear');
     }
 
-    protected function importSignatures()
+//    protected function importSignatures()
+//    {
+//        $map = ['signature_id' => 'id',
+//            'nom' => 'name',
+//            'active' => 'active'];
+//
+//        Signature::query()->truncate();
+//        foreach (DB::table($this->_oldDB . '.signatures')->get() as $e) {
+//            $c = new Signature();
+//            foreach ($map as $old => $new) {
+//                $c->setAttribute($new, $e->$old);
+//            }
+//            $credits = '<a href="' . $e->fbcredit . '" target="_blank">' . $e->fblink . '</a>';
+//            if ($e->partnercredit !== '') {
+//                $credits = '<a href="' . $e->partnercredit . '" target="_blank">' . $e->partnerlink . '</a>' . $credits;
+//            }
+//            $c->setAttribute('credits', $credits);
+//            $c->save();
+//        }
+//
+//    }
+
+    protected function importQuotes()
     {
-        $map = ['signature_id' => 'id',
-            'nom' => 'name',
-            'active' => 'active'];
-
-        Signature::query()->truncate();
-        foreach (DB::table($this->_oldDB . '.signatures')->get() as $e) {
-            $c = new Signature();
+        $map = ['demande_id' => 'id',
+            'type' => 'type',
+            'pages' => 'pages',
+            'liens' => 'links',
+            'langues' => 'langs',
+            'details' => 'message',
+            'date' => 'created_at',
+            'status' => 'status',
+            'revendeur' => 'reseller',
+            'utilisateur' => 'user',
+            'administrateur' => 'admin',
+            'coupon' => 'coupon',
+            'gclid' => 'gclid'];
+
+        FluidbookQuote::truncate();
+        foreach (DB::table($this->_oldDB . '.demandes')->get() as $e) {
+            $c = new FluidbookQuote();
             foreach ($map as $old => $new) {
                 $c->setAttribute($new, $e->$old);
             }
-            $credits = '<a href="' . $e->fbcredit . '" target="_blank">' . $e->fblink . '</a>';
-            if ($e->partnercredit !== '') {
-                $credits = '<a href="' . $e->partnercredit . '" target="_blank">' . $e->partnerlink . '</a>' . $credits;
-            }
-            $c->setAttribute('credits', $credits);
             $c->save();
         }
-
     }
 
 }
index b06f38211ed88e9b5b74ae6d067ba253e093f852..bf10911be80ccfef9a6213035e828fbc8ba84583 100644 (file)
@@ -50,7 +50,7 @@ class FluidbookQuote extends CubistMagicAbstractModel
         $this->addField('message', 'Textarea', 'Message');
         $this->addField('gclid', 'Text', 'Google Adwords ID (gclid)');
         $this->addField('coupon', 'Text', 'Coupon');
-        $this->addField('admin', 'SelectFromModel', 'Administrateur', ['optionsmodel' => User::class, 'attribute' => 'nameWithCompany']);
-        $this->addField('reseller', 'SelectFromModel', 'Revendeur', ['optionsmodel' => User::class, 'attribute' => 'nameWithCompany']);
+        $this->addField('admin', 'SelectFromModel', 'Administrateur', ['optionsmodel' => User::class, 'attribute' => 'nameWithCompany', 'column' => true]);
+        $this->addField('reseller', 'SelectFromModel', 'Revendeur', ['optionsmodel' => User::class, 'attribute' => 'nameWithCompany', 'column' => true]);
     }
 }