--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Console\Commands\Base\ToolboxCommand;
+use App\Models\FluidbookCollection;
+use App\Models\FluidbookAuditLink;
+use App\Models\FluidbookPublication;
+
+class addFluidbookHemsleyToCollection extends ToolboxCommand
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'fluidbook:fill-hemsley-collection {--sync}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = '';
+
+ /**
+ * Execute the console command.
+ */
+ public function handle()
+ {
+ //
+ //$f->generateThumbnailsPreview($this->option('sync', false));
+ $data = FluidbookPublication::getFluidbooksHemsley();
+ $instance = new FluidbookCollection();
+ $instance->updateHemsleyCollection($data);
+ }
+}
{
dispatch_sync(new AuditLink($this));
}
+
+ public function updateHemsleyCollection($data) {
+ if($this->title === "Audit Hemsley") {
+ dd('ok');
+ $publications = json_decode($this->publications,true) ?? [];
+ foreach ($data as $fb) {
+ // Vérifier si le fluidbook n'existe pas déjà dans la collection
+ if(array_filter($publications, function($n) use($fb) { return $n['fluidbooks'] !== $fb; })) {
+ $publications[] = [
+ 'fluidbook' => $fb,
+ 'export' => '',
+ ];
+ }
+ }
+ $this->publications[] = json_encode($publications);
+ $this->save();
+ }
+ }
}
return FluidbookPublication::withoutGlobalScopes()->find($id)->protected_path($path);
});
}
+
+ public static function getFluidbooksHemsley() {
+ return static::where('c_title', 'LIKE', '%Hemsley Fraser -%')->pluck('id');
+ }
}
--- /dev/null
+<?php
+
+namespace App\SubForms;
+
+use Cubist\Backpack\Magic\SubForm;
+use Cubist\Backpack\Magic\Fields\LinkButton;
+
+
+// __('!! e-Learning')
+class FluidbookAuditLinkButtons extends SubForm
+{
+ public function init()
+ {
+ parent::init();
+
+ $this->addField('download_audit', LinkButton::class, __('Télécharger l\'audit'), [
+ 'when' => ["enable_audit" => 1],
+ 'value' => backpack_url('/'),
+ 'translatable' => false,
+ 'attributes' => [ 'class' => 'form-control some-class'],
+ ]);
+ $this->addField('update_fluidbooks', LinkButton::class, __('Mettre à jour les publications'), [
+ 'when' => ["enable_audit" => 1],
+ 'value' => backpack_url('/'),
+ 'translatable' => false]
+ );
+ }
+}