Fixed saving logic for custom buttons

This commit is contained in:
Julian Prieber 2024-09-16 15:19:35 +02:00
parent cab5e4193c
commit 1abab3fd40
1 changed files with 6 additions and 3 deletions

View File

@ -195,13 +195,16 @@ class UserController extends Controller
$LinkURL = $request->link;
// Step 3: Load Link Type Logic
if($request->typename == 'predefined') {
$button = Button::where('name', $request->button)->first();
if($request->typename == 'predefined' || $request->typename == 'link') {
// Determine button id based on whether a custom or predefined button is used
$button_id = ($request->typename == 'link') ? ($request->GetSiteIcon == 1 ? 2 : 1) : null;
$button = ($request->typename != 'link') ? Button::where('name', $request->button)->first() : null;
$linkData = [
'link' => $LinkURL,
'title' => $LinkTitle ?? $button?->alt,
'user_id' => Auth::user()->id,
'button_id' => $button?->id,
'button_id' => $button?->id ?? $button_id,
'type' => $request->typename // Save the link type
];
} else {