public function fetchProducts($filters = array()) {
print_r($filters);
$Product = new Product;
if (array_key_exists('search', $filters))
$Product->where('name', 'LIKE', '%'.$filters['search'].'%');
if (array_key_exists('type', $filters))
$Product->where('type_id', 1);
if (array_key_exists('brand', $filters))
$Product->where('brand_id', $filters['brand']);
$Product->get();
return $Product;
}
但无论来自哪个过滤器,它返回的所有产品,似乎不顾一切。
我在做什么错?
你用雄辩的ORM? – Ronser 2014-11-22 10:31:28
@罗塞尔是的,我是。 – imperium2335 2014-11-22 10:31:57