From 1abab3fd4014b6b4961b55cd595a2109be3844d3 Mon Sep 17 00:00:00 2001 From: Julian Prieber Date: Mon, 16 Sep 2024 15:19:35 +0200 Subject: [PATCH] Fixed saving logic for custom buttons --- app/Http/Controllers/UserController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 2ec7a54..3ab5c86 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -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 {