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

nanadjei2's avatar

Remove URL query Parameters form url

I want to get the slug of a product but as part of that I am performing a query to get some data related to the product form another table. This is how am displaying my product in my .blade view;

<form action="{{ route('user.showProduct', $productProductOption->product->slug) }}" method="GET">

    <input type="hidden" value="{{ $productProductOption->id }}" name="productProductOption_id">

    <a class="goToSingleProduct" href="javascript:void(0)" type="submit">

            <img class="img-responsive" 
                  src="{{ $productProductOption ? $productProductOption::display($resultsProductImages[$i]) :asset('assets/theme/images/latest-product.jpg') }}" alt="" width="270" height="350"/>
                    <?php $i+=1; ?>
    </a>
                        
</form>

This is how my controller looks like:

   public function show(Request $request, $slug)
{
    $product = \App\Product::where('slug', $slug)->firstOrFail();
    
    $productProductOption = ProductProductOption::findOrFail($request->request->get('productProductOption_id'));

}

Anytime I click on a product to view its detail on the next page I get something like http://127.0.0.1:8000/product/freelance-top?productProductOption_id=24.

But I want to instead get http://127.0.0.1:8000/product/freelance-top in the url

Please kindly help me fix this.

0 likes
1 reply
Borisu's avatar

You're getting the query string because your form method is get. You either just use an anchor tag, or a post request.

<a href="{{ route('user.showProduct', $productProductOption->product->slug) }}">
or
<form method="POST" action="{{ route('user.showProduct', $productProductOption->product->slug) }}">
1 like

Please or to participate in this conversation.