namespace App\Console\Commands;
+use App\Models\FluidbookQuote;
use App\Models\Signature;
use Cubist\Backpack\app\Console\Commands\CubistCommand;
use Illuminate\Support\Facades\DB;
{
$actions = [
'Backup current database' => 'backup',
- 'Import Signatures' => 'importSignatures',
+ 'Import Quotes' => 'importQuotes',
'Migrate magic models' => 'migrate',
'Clean caches' => 'cleanCache'
];
$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();
}
-
}
}
$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]);
}
}