From: Vincent Vanwaelscappel Date: Wed, 25 Nov 2020 15:31:48 +0000 (+0100) Subject: wip #3753 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ad365abbb8343cd4b03216e5a40d6deb65c55ad6;p=fluidbook-toolbox.git wip #3753 @1 --- diff --git a/app/Console/Commands/WorkshopMigration.php b/app/Console/Commands/WorkshopMigration.php index 9e16e00be..1256ce80c 100644 --- a/app/Console/Commands/WorkshopMigration.php +++ b/app/Console/Commands/WorkshopMigration.php @@ -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 = '' . $e->fblink . ''; +// if ($e->partnercredit !== '') { +// $credits = '' . $e->partnerlink . '' . $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 = '' . $e->fblink . ''; - if ($e->partnercredit !== '') { - $credits = '' . $e->partnerlink . '' . $credits; - } - $c->setAttribute('credits', $credits); $c->save(); } - } } diff --git a/app/Models/FluidbookQuote.php b/app/Models/FluidbookQuote.php index b06f38211..bf10911be 100644 --- a/app/Models/FluidbookQuote.php +++ b/app/Models/FluidbookQuote.php @@ -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]); } }