gpt4 book ai didi

php - Laravel 价格过滤器

转载 作者:行者123 更新时间:2023-12-01 08:41:55 25 4
gpt4 key购买 nike

我的 Laravel 项目上有价格过滤器 slider ,我正在使用 Bootstrap slider .

这是我查看的输入代码

<input name="price" id="ex2" type="text" class="span2" value="" data-slider-min="10" data-slider-max="2000" data-slider-step="5" data-slider-value="[250,450]" onchange="checkBoxHandler()"/>

这是我的 Javascript 自动提交脚本

<script> 
function checkBoxHandler() {
$('#color_form').submit();
}

$("#ex2").slider({});
</script>

这是我的 Controller

$price = $request->price;
if (request()->has('price')) {
$products = product::whereBetween('price', [$price])
->whereHas('categories', function ($query) use ($tags){
$query->where('name', $tags);
})->paginate(20);

我收到以下错误

SQLSTATE[HY093]: Invalid parameter number (SQL: select count(*) as aggregate from products where price between 250,1400 and swim and exists (select * from categories inner join category_product on categories.id = category_product.category_id where products.id = category_product.product_id and name = ?))

最佳答案

对于whereBetween,您需要传递数组。

whereBetween('price', explode(',', $price))

关于php - Laravel 价格过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46072942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com