I want to filter some data using price but when we echo request value it give correct but when I put this in query it show "?"
my ajax call
<script>
$(document).ready(function() {
$("#price_filter").on("change", function() {
var price = this .value;
var _token = $('input[name="_token"]').val();
$.ajax({
url:"{{ route('indexController.pricefilter') }}",
type:"POST",
dataType:"json",
data:{price,_token},
success: function(response){
console.log(response);
// $("#filterdata").html(response);
}
});
})
})
</script>
my route
Route::post('indexController/pricefilter','indexController@pricefilter')->name('indexController.pricefilter');
my function
public function pricefilter(Request $request){
echo $price = $request->get('price');
return $products = DB::table('products')
->where('price','=', $price)
->tosql();
}
my query result
400
select * from `products` where `price` = ?
it show actually like
select * from `products` where `price` = 400
Here is result
array:1 [
0 => array:3 [
"query" => "select * from `products` where `price` <= ?"
"bindings" => array:1 [
0 => "1001"
]
"time" => 3.87
]
]
dd($request->price);, still null?->where('price','<', $prod_price)to->where('price','<', 500)its work fine