thangth318
New member
- Oct 29, 2022
- 0
- 0
- 0
I've searched the whole forums but I only get the code with no instruction on how to execute it!See the old messages in this thread!
this is the code that I fund:
PHP:
if(isset($_GET['migrate'])) {
$result = database()->query("SELECT * FROM `links` WHERE `type` = 'biolink'");
while($row = $result->fetch_object()) {
$row->settings = json_decode($row->settings);
/* Migrate the avatar */
$settings = json_encode([
'image' => $row->settings->image,
'size' => '125',
'border_radius' => 'straight',
]);
/* Database query */
db()->insert('biolinks_blocks', [
'user_id' => $row->user_id,
'link_id' => $row->link_id,
'type' => 'avatar',
'settings' => $settings,
'datetime' => \Altum\Date::$date,
'order' => -5,
]);
/* Migrate the socials */
$settings = json_encode([
'color' => $row->settings->socials_color,
'socials' => $row->settings->socials
]);
/* Database query */
db()->insert('biolinks_blocks', [
'user_id' => $row->user_id,
'link_id' => $row->link_id,
'type' => 'socials',
'settings' => $settings,
'datetime' => \Altum\Date::$date,
'order' => 999,
]);
/* Migrate the Heading */
$settings = json_encode([
'heading_type' => 'h1',
'text' => $row->settings->title,
'text_color' => $row->settings->text_color,
]);
/* Database query */
db()->insert('biolinks_blocks', [
'user_id' => $row->user_id,
'link_id' => $row->link_id,
'type' => 'heading',
'settings' => $settings,
'datetime' => \Altum\Date::$date,
'order' => -4,
]);
/* Migrate the paragraph */
$settings = json_encode([
'text' => $row->settings->description,
'text_color' => $row->settings->text_color,
]);
/* Database query */
db()->insert('biolinks_blocks', [
'user_id' => $row->user_id,
'link_id' => $row->link_id,
'type' => 'paragraph',
'settings' => $settings,
'datetime' => \Altum\Date::$date,
'order' => -3,
]);
/* Clear the cache */
\Altum\Cache::$adapter->deleteItemsByTag('biolinks_links_user_' . $row->user_id);
}
}
if(isset($_GET['migrate'])) {
$result = database()->query("SELECT * FROM `biolinks_blocks` WHERE `type` = 'text'");
while($row = $result->fetch_object()) {
$row->settings = json_decode($row->settings);
/* Migrate the Heading */
$settings = json_encode([
'heading_type' => 'h1',
'text' => $row->settings->title,
'text_color' => $row->settings->title_text_color,
]);
/* Database query */
db()->insert('biolinks_blocks', [
'user_id' => $row->user_id,
'link_id' => $row->link_id,
'type' => 'heading',
'settings' => $settings,
'datetime' => \Altum\Date::$date,
'order' => $row->order,
]);
/* Migrate the paragraph */
$settings = json_encode([
'text' => $row->settings->description,
'text_color' => $row->settings->description_text_color,
]);
/* Database query */
db()->insert('biolinks_blocks', [
'user_id' => $row->user_id,
'link_id' => $row->link_id,
'type' => 'paragraph',
'settings' => $settings,
'datetime' => \Altum\Date::$date,
'order' => $row->order+1,
]);
db()->where('biolink_block_id', $row->biolink_block_id)->delete('biolinks_blocks');
/* Clear the cache */
\Altum\Cache::$adapter->deleteItemsByTag('biolinks_links_user_' . $row->user_id);
}
}