Skip to content

Commit 1abab3f

Browse files
committed
Fixed saving logic for custom buttons
1 parent cab5e41 commit 1abab3f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

app/Http/Controllers/UserController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,16 @@ public function saveLink(Request $request)
195195
$LinkURL = $request->link;
196196

197197
// Step 3: Load Link Type Logic
198-
if($request->typename == 'predefined') {
199-
$button = Button::where('name', $request->button)->first();
198+
if($request->typename == 'predefined' || $request->typename == 'link') {
199+
// Determine button id based on whether a custom or predefined button is used
200+
$button_id = ($request->typename == 'link') ? ($request->GetSiteIcon == 1 ? 2 : 1) : null;
201+
$button = ($request->typename != 'link') ? Button::where('name', $request->button)->first() : null;
202+
200203
$linkData = [
201204
'link' => $LinkURL,
202205
'title' => $LinkTitle ?? $button?->alt,
203206
'user_id' => Auth::user()->id,
204-
'button_id' => $button?->id,
207+
'button_id' => $button?->id ?? $button_id,
205208
'type' => $request->typename // Save the link type
206209
];
207210
} else {

0 commit comments

Comments
 (0)