Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

NoLAstNamE's avatar

Get value of a parameter passed in the URL

In Laravel, how to get a query string value if the request is coming from a frontend request?

This is what the URL looks like: http://example.com/filter?type_id=1

I tried accessing it in my controller method using $request->query('type_id') and $request->get('type_id') but I'm getting null.

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

Should be as you have written

Make sure you are hitting the right route.

How is the site hosted? It could be that the querystring is not passed on to the index.php

1 like
NoLAstNamE's avatar

@Snapey Sorry for the late response, I got it working, but I don't know what happened I tried deleting the code and writing it again and it works. This is weird, sorry.

Please or to participate in this conversation.