Skip to content

Commit cc406d1

Browse files
committed
Fix Updater
1 parent c1a4755 commit cc406d1

File tree

2 files changed

+64
-66
lines changed

2 files changed

+64
-66
lines changed
Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?php // Runs before updating
2+
use Illuminate\Database\Schema\Blueprint;
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Support\Facades\DB;
5+
use App\Models\Link;
6+
7+
// Disable execution time limit
8+
set_time_limit(0);
9+
210
if(trim(file_get_contents(base_path("version.json"))) < '4.0.0'){
311
try {
412
$file = base_path('storage/RSTAC');
@@ -8,6 +16,59 @@
816
}
917
} catch (Exception $e) {}
1018
}
11-
?>
12-
{{-- update links table to new structure --}}
13-
@include('components.updater.links-table-translation-layer')
19+
20+
// Check version
21+
if (trim(file_get_contents(base_path("version.json"))) < '4.8.1') {
22+
23+
// First, check if the 'type' and 'type_params' columns exist, and add them if they don't
24+
if (!Schema::hasColumn('links', 'type')) {
25+
Schema::table('links', function (Blueprint $table) {
26+
$table->string('type')->nullable();
27+
});
28+
}
29+
30+
if (!Schema::hasColumn('links', 'type_params')) {
31+
Schema::table('links', function (Blueprint $table) {
32+
$table->text('type_params')->nullable();
33+
});
34+
}
35+
36+
// Get all links
37+
$links = Link::all();
38+
39+
foreach ($links as $link) {
40+
$type = null;
41+
42+
// Assign type based on button_id
43+
switch ($link->button_id) {
44+
case "1":
45+
case "2":
46+
$type = "link";
47+
break;
48+
case "43":
49+
$type = "spacer";
50+
break;
51+
case "42":
52+
$type = "heading";
53+
break;
54+
case "93":
55+
$type = "text";
56+
break;
57+
case "44":
58+
$type = "telephone";
59+
break;
60+
case "6":
61+
$type = "email";
62+
break;
63+
case "96":
64+
$type = "vcard";
65+
break;
66+
}
67+
68+
// Update the link if a type was assigned
69+
if ($type !== null) {
70+
$link->type = $type;
71+
$link->save();
72+
}
73+
}
74+
}

resources/views/components/updater/links-table-translation-layer.blade.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)