From ab3471b4283fa4620877990629fb22669d7febcb Mon Sep 17 00:00:00 2001 From: aprillio Date: Tue, 6 Jul 2021 17:19:09 +0700 Subject: [PATCH] add ability to redirect a link with query string --- app/Http/Controllers/UserController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 09ca38a..9a252f2 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -85,12 +85,19 @@ class UserController extends Controller public function clickNumber(request $request) { $link = $request->link; + $query = $request->query(); $linkId = $request->id; if(empty($link && $linkId)) { return abort(404); } + + if(!empty($query)) { + $qs = ''; + foreach($query as $qk => $qv) { $qs .= $qk .'='. $qv; } + $link = $link .'?'. $qs; + } Link::where('id', $linkId)->increment('click_number', 1);