From d000bfeb6873ee156440d6e75db59155697fd617 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 3 Jul 2025 13:40:20 +0200 Subject: [PATCH] wip #7600 @1 --- app/Models/ELearningMedia.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Models/ELearningMedia.php b/app/Models/ELearningMedia.php index 0fdf3b962..cdcd4c8b8 100644 --- a/app/Models/ELearningMedia.php +++ b/app/Models/ELearningMedia.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Fields\ElearningLocale; use App\Fields\SCORMVersion; use App\Http\Controllers\Admin\Operations\ChangeownerOperation; use App\Http\Controllers\Admin\Operations\ELearningMedia\ImportOperation; @@ -47,6 +48,7 @@ class ELearningMedia extends ToolboxModel $this->addHashField(); + $this->addField(['name' => 'client', 'label' => __('Nom du client'), 'type' => 'Text', @@ -61,6 +63,13 @@ class ELearningMedia extends ToolboxModel 'column_label' => __('Projet') ]); + $this->addField(['name' => 'locale', + 'label' => __('Langue'), + 'type' => ElearningLocale::class, + 'default' => 'en', + 'column' => true, + 'column_label' => '']); + $this->addField('type', Hidden::class, __('Type'), ['column' => true]); $this->addField('title', Text::class, __('Titre'), ['column' => true]); $this->addField(['name' => 'scorm_version', @@ -81,14 +90,14 @@ class ELearningMedia extends ToolboxModel $this->addField('complete_pct', Percent::class, __('Marquer terminé quand ce pourcentage est lu'), ['default' => 75, 'when' => ['complete_button' => 0, 'type' => ['logical_operator' => 'OR', 'values' => ['video', 'audio']]]]); } - public function preSave() + public function onSaving(): bool { $file = $this->getMediaInField('file')->first(); if ($file !== null) { $spl = new \SplFileInfo($file->getPath()); $this->setAttribute('type', self::getType($spl->getExtension())); } - return parent::preSave(); + return parent::onSaving(); } public static function getType($ext) @@ -149,7 +158,7 @@ class ELearningMedia extends ToolboxModel $vdir->file_put_contents('pdfjs/web/viewer.css', $css); } $vdir->copy($file, 'media.' . $ext); - $vdir->file_put_contents('index.html', view('elearningmedia.index', ['complete_pct' => $complete_pct,'title' => $title, 'type' => $type])); + $vdir->file_put_contents('index.html', view('elearningmedia.index', ['complete_pct' => $complete_pct, 'title' => $title, 'type' => $type])); $vdir->sync(true); return $title; } -- 2.39.5