Laravel 高级搜索查询修复
问题描述
我有一个包含多个输入和选择框的搜索表单,我需要帮助来获取查询中的条件,以便每个部分单独工作并同时工作.
这是我的刀片代码:
</div><!-- ./filter-tag-group --></div><!-- ./sidebar-content --></表单>
这是我的路线:
最后我的函数代码是:
我的模特关系:
product
型号:
Option
模型:
子选项
模型:
品牌
型号:
注意
我的 brands
搜索来自产品表,其中每个产品都有 brand_id
列.
但是
我的 suboptions
来自名为 product_suboption
的第三个表(如您在我的模型代码中看到的),我在其中保存了 product_id
和 suboption_id
.
SOLVED
在玩了数周的代码之后,我终于为自己找到了正确的结果(在我的情况下,它对其他人有效,可能适用于其他建议的答案)
<块引用>
注意:我的大部分定价问题都是用 (int)
解决的,正如你在我的代码中看到的 (int)Input::get('min_price')
和(int)Input::get('max_price')
.
特别感谢 Ravindra Bhanderi 的 count($request['']
建议.
I have a search form with multiple input and select boxes I need help to get if conditions in my query in order to each part works separately and all at once.
here is my blade codes:
and this is my route:
finally my function code is:
My models relations:
product
model:
Option
model:
Suboption
model:
Brand
model:
note
My brands
search is coming from products table where I have column brand_id
for each product.
BUT
My suboptions
come from 3rd table named product_suboption
(as you see in my models codes) where i save product_id
and suboption_id
.
SOLVED
After weeks of playing with codes finally I came to the right results for myself (in my case it works this way for others maybe works with other suggested answers)
NOTE: most of my pricing issues solved with
(int)
as you see in my codes(int)Input::get('min_price')
and(int)Input::get('max_price')
.
Special thanks to Ravindra Bhanderi for his count($request['']
suggestion.
这篇关于Laravel 高级搜索查询修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!