我的应用程序返回错误,我需要知道原因。我提出了一个 AJAX 请求,以获取他在热卖或特价商品中选择的所有产品,并且...
如果我删除此查询功能,它会返回数据。如何将此请求选中框传递给此函数?
函数 App\Http\Controllers\Website\AllProductController::App\Http\Controllers\Website\{closure}() 的参数太少,1 传入 /...../vendor/laravel/framework/src/Illuminate /Database/Eloquent/Builder.php 在第 226 行,预计正好 2
public function ajax_category(Request $request)
{
if(isset($request->price) && isset($request->categories_id))
{
$product_category = $request->categories_id;
// change the value from string to array.
if (isset($request->selectedbox) && $request->selectedbox !='') {
$pairs = $request->selectedbox;
$newArray = explode(",", $pairs);
}
if (!empty($request->categories_id)) {
$max = $request->max;
$min = $request->min;
} else {
$min = product_model::where('pactive', 1)->select('MIN("price")')->first();
$max = product_model::where('pactive', 1)->select('MAx("price")')->first();
}
// change the value from string to array.
if (!empty($request->priceRange)) {
$currentRange = $request->priceRange;
$priceArray = explode(",", $currentRange);
$firstPrice = $priceArray[0];
$secondPrice = $priceArray[1];
} else {
$firstPrice = $min;
$secondPrice = $max;
}
$products = product_model::where('category', $request->categories_id)
->whereBetween('price', [$firstPrice, $secondPrice]);
if (isset($request->selectedbox) && $request->selectedbox !='') {
$products = $products->where(function ($query,Request $request) {
$pairs = $request->selectedbox;
$newArray = explode(",", $pairs);
$query->whereIn('poffertype',implode(',', $newArray))
->orwhereIn('brand', implode(',', $newArray))
->orwhereIn('brand_ar', implode(',', $newArray));
});
}
青春有我