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

Osho's avatar
Level 1

when I dd($request->cat_id) I get this "1min_price=max_price=search="

I am trying to get request data from my inputsID but it's rendering my data the wrong way, how do I fix this? ````"1min_price=max_price=search="what I am getting on dd($request->cat_id) instead of just the value for$cat_id```.

Inputs

<div style="display: inline-block; margin-top:12px; text-align: center;">
                    <input type="text" id="catID" value="{{$catByUser}}" hidden/>
                    <input type="number" id="minpriceID" min="0" class="form-control" style="margin: inherit;" placeholder="Min Price">
                    <input type="number" id="maxpriceID" min="0" class="form-control" style="margin: inherit;" placeholder="Max Price">
                    <input type="text" id="search" class="form-control" style="margin: inherit;" placeholder="search product by name">
                    <div style="margin-top:inherit;">
                        <button class="login-btn form-control" id="findBtn" style="margin: inherit; border-left: inset;"> <span class="fas fa-filter"></span> Filter</button>
                    </div>
                </div>
<script>
$(document).ready(function(){
  $("#findBtn").click(function(){
    var cat = $("#catID").val();
    var minprice = $('#minpriceID').val();
    var maxprice = $('#maxpriceID').val();
    var search = $('#search').val();
    
    $.ajax({
      type: 'get',
      dataType: 'html',
      url: '{{url('/productsCat')}}',
      data: 'cat_id=' + cat + 'min_price=' + minprice + 'max_price=' + maxprice + 'search=' + search,
      success:function(response){
        console.log(response);
        $("#productData").html(response);
      }
    });
  });
});
</script>
0 likes
3 replies
tisuchi's avatar

@osho Can you show your controller code from where you send $catByUser data?

1 like
Osho's avatar
Level 1
public function show($id, $slug, Request $request)
    {
        $cat = $id;
        // dd($cat);
        $catByUser = $cat;
        $catname = ProductCategory::find($slug);
        $subcategory = SubCategory::with(['productCategory'])->orderBy('name')->get();
        $data = Product::where('categories_id', $cat)->get();
        // dd($catname);
        $cart = User::findorfail(auth()->user()->id)->cart;
        $user = auth()->user()->id;
        $messages = User::findorfail($user)->latestmessaging->count();
        // dd($category);
        return view('frontEnd.product-category', compact('data', 'catname', 'catByUser', 'subcategory', 'cart', 'messages'));
    }

Please or to participate in this conversation.