2023-05-05 14:43:17 +02:00
|
|
|
<?php // Runs before updating
|
2024-06-20 12:47:01 +02:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use App\Models\Link;
|
|
|
|
|
|
|
|
set_time_limit(0);
|
|
|
|
|
2023-05-05 14:43:17 +02:00
|
|
|
if(trim(file_get_contents(base_path("version.json"))) < '4.0.0'){
|
|
|
|
try {
|
|
|
|
$file = base_path('storage/RSTAC');
|
|
|
|
if (!file_exists($file)) {
|
|
|
|
$handleFile = fopen($file, 'w');
|
|
|
|
fclose($handleFile);
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {}
|
2024-06-20 12:24:54 +02:00
|
|
|
}
|
2024-06-20 12:47:01 +02:00
|
|
|
|
|
|
|
if (trim(file_get_contents(base_path("version.json"))) < '4.8.1') {
|
|
|
|
|
|
|
|
if (!Schema::hasColumn('links', 'type')) {
|
|
|
|
Schema::table('links', function (Blueprint $table) {
|
|
|
|
$table->string('type')->nullable();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Schema::hasColumn('links', 'type_params')) {
|
|
|
|
Schema::table('links', function (Blueprint $table) {
|
|
|
|
$table->text('type_params')->nullable();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$links = Link::all();
|
|
|
|
|
|
|
|
foreach ($links as $link) {
|
2024-09-16 14:29:28 +02:00
|
|
|
$type = null;
|
|
|
|
$params = false;
|
2024-06-20 12:47:01 +02:00
|
|
|
|
2024-09-16 14:29:28 +02:00
|
|
|
switch ($link->button_id) {
|
|
|
|
case "1":
|
|
|
|
$type = "link";
|
|
|
|
break;
|
|
|
|
case "2":
|
|
|
|
$type = "link";
|
|
|
|
break;
|
|
|
|
case "43":
|
|
|
|
$type = "spacer";
|
|
|
|
$params = true;
|
|
|
|
break;
|
|
|
|
case "42":
|
|
|
|
$type = "heading";
|
|
|
|
$params = true;
|
|
|
|
break;
|
|
|
|
case "93":
|
|
|
|
$type = "text";
|
|
|
|
$params = true;
|
|
|
|
break;
|
|
|
|
case "44":
|
|
|
|
$type = "telephone";
|
|
|
|
break;
|
|
|
|
case "6":
|
|
|
|
$type = "email";
|
|
|
|
break;
|
|
|
|
case "96":
|
|
|
|
$type = "vcard";
|
|
|
|
break;
|
|
|
|
}
|
2024-06-20 12:47:01 +02:00
|
|
|
|
2024-09-16 14:29:28 +02:00
|
|
|
if ($type !== null) {
|
|
|
|
$link->type = $type;
|
|
|
|
if ($params === true) {
|
|
|
|
$link->type_params = json_encode(["custom_html" => true]);
|
2024-06-20 12:47:01 +02:00
|
|
|
}
|
2024-09-16 14:29:28 +02:00
|
|
|
$link->save();
|
2024-06-20 12:47:01 +02:00
|
|
|
}
|
2024-09-16 14:29:28 +02:00
|
|
|
}
|
2024-06-20 12:47:01 +02:00
|
|
|
}
|