add ability to redirect a link with query string

This commit is contained in:
aprillio 2021-07-06 17:19:09 +07:00
parent 4c3163674f
commit ab3471b428
1 changed files with 7 additions and 0 deletions

View File

@ -85,6 +85,7 @@ class UserController extends Controller
public function clickNumber(request $request) public function clickNumber(request $request)
{ {
$link = $request->link; $link = $request->link;
$query = $request->query();
$linkId = $request->id; $linkId = $request->id;
if(empty($link && $linkId)) if(empty($link && $linkId))
@ -92,6 +93,12 @@ class UserController extends Controller
return abort(404); 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); Link::where('id', $linkId)->increment('click_number', 1);
return redirect()->away($link); return redirect()->away($link);