From f39f5e48fbe170986dad60a17181d8c78b4d4d92 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 3 Feb 2026 16:43:25 +0100 Subject: [PATCH] wip #7868 @1 --- app/Models/ShortLink.php | 14 ++++++++++---- .../fluidbook_publication/link_editor.blade.php | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Models/ShortLink.php b/app/Models/ShortLink.php index 6abb23259..9529176d9 100644 --- a/app/Models/ShortLink.php +++ b/app/Models/ShortLink.php @@ -5,6 +5,7 @@ namespace App\Models; use App\Models\Base\ToolboxModel; use Cubist\Backpack\Magic\Fields\SelectFromArray; use Cubist\Backpack\Magic\Fields\Text; +use Cubist\Backpack\Magic\Fields\URL; use Cubist\Backpack\Magic\Traits\CustomDataSource; use DateTime; @@ -23,7 +24,7 @@ class ShortLink extends ToolboxModel protected $_enableRevisions = false; - protected $primaryKey = 'shorturl'; + protected $primaryKey = 'id'; public $incrementing = false; protected $keyType = 'string'; @@ -34,8 +35,10 @@ class ShortLink extends ToolboxModel parent::setFields(); $this->addField('server', SelectFromArray::class, __('Serveur'), ['options' => LinkShortener::getAvaiableShorteners()]); - $this->addField('url', Text::class, __('URL'), ['column' => true]); + $this->addField('url', URL::class, __('URL'), ['column' => true]); + $this->addField('shortlink', URL::class, __('Short URL'), ['column' => true, 'database_unique' => true]); $this->addOwnerField(['column' => false]); + } /** @@ -50,7 +53,8 @@ class ShortLink extends ToolboxModel $shorturl = 'https://' . $s['domain'] . '/' . $i->keyword; $time = new DateTime($i->timestamp); $d = [ - 'shorturl' => $shorturl, + 'id' => hash('sha256', $id . '/' . $i->keyword), + 'shortlink' => $shorturl, 'url' => $i->url, 'server' => $id, 'created_at' => $time, @@ -59,7 +63,7 @@ class ShortLink extends ToolboxModel 'created_ok' => '1', 'owner' => $s['owner'], ]; - $data[$shorturl] = $d; + $data[$d['id']] = $d; } } catch (\Exception $e) { @@ -72,4 +76,6 @@ class ShortLink extends ToolboxModel { return true; } + + } diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index c08a15d58..2c04dd71d 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -1,5 +1,6 @@ {{-- __('!! Editeur de liens') --}} @php + debugbar()->disable(); if($version==='stable'){ $scriptVersion='-stable'; }else{ -- 2.39.5