diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 009bd78..2ec7a54 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -979,6 +979,8 @@ class UserController extends Controller $newLink->up_link = $linkData['up_link']; $newLink->custom_css = $linkData['custom_css']; $newLink->custom_icon = $linkData['custom_icon']; + $newLink->type = $linkData['type']; + $newLink->type_params = $linkData['type_params']; // Set the user ID to the current user's ID $newLink->user_id = $user->id; diff --git a/resources/views/components/pre-update.blade.php b/resources/views/components/pre-update.blade.php index 8897737..bb9751d 100644 --- a/resources/views/components/pre-update.blade.php +++ b/resources/views/components/pre-update.blade.php @@ -4,7 +4,6 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\DB; use App\Models\Link; -// Disable execution time limit set_time_limit(0); if(trim(file_get_contents(base_path("version.json"))) < '4.0.0'){ @@ -17,10 +16,8 @@ if(trim(file_get_contents(base_path("version.json"))) < '4.0.0'){ } catch (Exception $e) {} } -// Check version if (trim(file_get_contents(base_path("version.json"))) < '4.8.1') { -// First, check if the 'type' and 'type_params' columns exist, and add them if they don't if (!Schema::hasColumn('links', 'type')) { Schema::table('links', function (Blueprint $table) { $table->string('type')->nullable(); @@ -33,42 +30,48 @@ if (!Schema::hasColumn('links', 'type_params')) { }); } - // Get all links $links = Link::all(); foreach ($links as $link) { - $type = null; + $type = null; + $params = false; - // Assign type based on button_id - switch ($link->button_id) { - case "1": - case "2": - $type = "link"; - break; - case "43": - $type = "spacer"; - break; - case "42": - $type = "heading"; - break; - case "93": - $type = "text"; - break; - case "44": - $type = "telephone"; - break; - case "6": - $type = "email"; - break; - case "96": - $type = "vcard"; - break; - } - - // Update the link if a type was assigned - if ($type !== null) { - $link->type = $type; - $link->save(); - } + 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; } + + if ($type !== null) { + $link->type = $type; + if ($params === true) { + $link->type_params = json_encode(["custom_html" => true]); + } + $link->save(); + } +} } \ No newline at end of file