--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Console\Commands\Base\ToolboxCommand;
+use App\Models\FluidbookPublication;
+use Illuminate\Support\Facades\DB;
+
+class SyncFluidbooksV3ToWorkshop extends ToolboxCommand
+{
+ protected $signature = 'syncfluidbooksv3toworkshop';
+ protected $description = 'Sync fluidbooks database to show on workshop fluidbooks made on toolbox';
+
+ public function handle()
+ {
+ // Delete fluidbook V3
+ DB::connection('extranet')->table('books')->where('version', "3")->delete();
+
+ $inserts = [];
+ $ids = [];
+
+ foreach (FluidbookPublication::withoutGlobalScopes()->where('created_ok', '1')->where('version', 3)->orderBy('id', 'ASC')->get() as $fb) {
+ /** @var $fb FluidbookPublication */
+ $i = ['book_id' => $fb->id,
+ 'version' => 3,
+ 'nom' => $fb->c_title,
+ 'lang' => $fb->locale,
+ 'region' => $fb->region,
+ 'theme' => $fb->theme,
+ 'proprietaire' => $fb->owner,
+ 'status' => $fb->status,
+ 'tache' => $fb->extranet_task ?? 0,
+ 'date' => (new \DateTime($fb->created_at))->getTimestamp(),
+ 'changedate' => (new \DateTime($fb->updated_at))->getTimestamp(),
+ 'numerotation' => $fb->page_numbers??'',
+ 'parametres' => $fb->settings,
+ 'hash' => $fb->hash,
+ 'cid' => $fb->cid,
+ ];
+ $inserts[] = $i;
+ $ids[] = $fb->id;
+ }
+
+ DB::connection('extranet')->table('books')->whereIn('book_id', $ids)->delete();
+ foreach ($inserts as $insert) {
+ DB::connection('extranet')->table('books')->insert($insert);
+ }
+ }
+}
'Migrate magic models' => 'migrate',
'Import documents' => 'importDocuments',
'Import publications' => 'importPublications',
+ 'Export publications' => 'exportPublications',
'Clean caches' => 'cleanCache'
];
return $res;
}
+ protected function exportPublications(){
+
+ }
+
protected function importPublications()
{
if ($this->option('publications') === 'none') {