@westag You can retrieve query string parameters from the Request service:
$category = Request::query('category');
If you use the façade, be sure to import it at the top of your view composer (use Request;).
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello people, how are you? I'm new to Laravel. So far I like it, but I have a problem.
I want to create a category menu in my left sidebar. When you click a random category it shows all the children from one category. See above.
category
category ( clicked )
- category
- category
- category
- category
- category
category
category
table categories
id parent name
1 0 category 1
2 0 category 2
3 1 child category
I thought maybe it is a good idea to create a view composer, because the category menu is shown on all pages. Problem is that I need the data from the url for ex( website.com?id=23&blabla=sd), so I can retrieve all the children from the category I clicked.
How can i access the GET variables in a view composer or what is a better way to do this in Laravel ?
Thanks for your answer.
Actually i needed the Route service to get the job done.
$current_params = Route::current()->parameter('hierarchy');
My route is
Route::get('category/{hierarchy}', 'CategoriesController@index')->where('hierarchy', '(.*)?');
Please or to participate in this conversation.