Skip to content

Commit 80523d4

Browse files
committed
Fix display issue on user page
#846
1 parent 1b574df commit 80523d4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

app/Http/Controllers/UserController.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,27 @@ public function littlelinkhome(request $request)
141141
$userinfo = User::select('id', 'name', 'littlelink_name', 'littlelink_description', 'theme', 'role', 'block')->where('id', $id)->first();
142142
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get();
143143

144-
$links = DB::table('links')->join('buttons', 'buttons.id', '=', 'links.button_id')->select('links.link', 'links.id', 'links.button_id', 'links.title', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get();
144+
$links = DB::table('links')
145+
->join('buttons', 'buttons.id', '=', 'links.button_id')
146+
->select('links.*', 'buttons.name') // Assuming 'links.*' to fetch all columns including 'type_params'
147+
->where('user_id', $id)
148+
->orderBy('up_link', 'asc')
149+
->orderBy('order', 'asc')
150+
->get();
151+
152+
// Loop through each link to decode 'type_params' and merge it into the link object
153+
foreach ($links as $link) {
154+
if (!empty($link->type_params)) {
155+
// Decode the JSON string into an associative array
156+
$typeParams = json_decode($link->type_params, true);
157+
if (is_array($typeParams)) {
158+
// Merge the associative array into the link object
159+
foreach ($typeParams as $key => $value) {
160+
$link->$key = $value;
161+
}
162+
}
163+
}
164+
}
145165

146166
return view('linkstack.linkstack', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]);
147167
}

0 commit comments

Comments
 (0)