Add link params
This commit is contained in:
parent
31c8ba0daa
commit
425eedfccc
|
@ -979,6 +979,8 @@ class UserController extends Controller
|
||||||
$newLink->up_link = $linkData['up_link'];
|
$newLink->up_link = $linkData['up_link'];
|
||||||
$newLink->custom_css = $linkData['custom_css'];
|
$newLink->custom_css = $linkData['custom_css'];
|
||||||
$newLink->custom_icon = $linkData['custom_icon'];
|
$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
|
// Set the user ID to the current user's ID
|
||||||
$newLink->user_id = $user->id;
|
$newLink->user_id = $user->id;
|
||||||
|
|
|
@ -4,7 +4,6 @@ use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Models\Link;
|
use App\Models\Link;
|
||||||
|
|
||||||
// Disable execution time limit
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
if(trim(file_get_contents(base_path("version.json"))) < '4.0.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) {}
|
} catch (Exception $e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check version
|
|
||||||
if (trim(file_get_contents(base_path("version.json"))) < '4.8.1') {
|
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')) {
|
if (!Schema::hasColumn('links', 'type')) {
|
||||||
Schema::table('links', function (Blueprint $table) {
|
Schema::table('links', function (Blueprint $table) {
|
||||||
$table->string('type')->nullable();
|
$table->string('type')->nullable();
|
||||||
|
@ -33,42 +30,48 @@ if (!Schema::hasColumn('links', 'type_params')) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all links
|
|
||||||
$links = Link::all();
|
$links = Link::all();
|
||||||
|
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
$type = null;
|
$type = null;
|
||||||
|
$params = false;
|
||||||
|
|
||||||
// Assign type based on button_id
|
switch ($link->button_id) {
|
||||||
switch ($link->button_id) {
|
case "1":
|
||||||
case "1":
|
$type = "link";
|
||||||
case "2":
|
break;
|
||||||
$type = "link";
|
case "2":
|
||||||
break;
|
$type = "link";
|
||||||
case "43":
|
break;
|
||||||
$type = "spacer";
|
case "43":
|
||||||
break;
|
$type = "spacer";
|
||||||
case "42":
|
$params = true;
|
||||||
$type = "heading";
|
break;
|
||||||
break;
|
case "42":
|
||||||
case "93":
|
$type = "heading";
|
||||||
$type = "text";
|
$params = true;
|
||||||
break;
|
break;
|
||||||
case "44":
|
case "93":
|
||||||
$type = "telephone";
|
$type = "text";
|
||||||
break;
|
$params = true;
|
||||||
case "6":
|
break;
|
||||||
$type = "email";
|
case "44":
|
||||||
break;
|
$type = "telephone";
|
||||||
case "96":
|
break;
|
||||||
$type = "vcard";
|
case "6":
|
||||||
break;
|
$type = "email";
|
||||||
}
|
break;
|
||||||
|
case "96":
|
||||||
// Update the link if a type was assigned
|
$type = "vcard";
|
||||||
if ($type !== null) {
|
break;
|
||||||
$link->type = $type;
|
|
||||||
$link->save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($type !== null) {
|
||||||
|
$link->type = $type;
|
||||||
|
if ($params === true) {
|
||||||
|
$link->type_params = json_encode(["custom_html" => true]);
|
||||||
|
}
|
||||||
|
$link->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue