Answer the question
In order to leave comments, you need to log in
How to build a query?
$body_type = implode("','",$body_type);
$body_type = "'".$body_type."'";
echo $body_type;
$poisks = DB::table('items')
->where('brand',$brand)
->where('location',$location)
->where('fuel_type',$fuel_type)
->whereBetween('price', [$price_from, $price_to])
->whereIn('body_type', [$body_type])
->whereIn('model', ['100','80','q5','a1'])
->orderBy('id', 'asc')
->paginate(5);
dd($poisks);
Answer the question
In order to leave comments, you need to log in
Because first they learn, then they write, and not vice versa.
First, $body_type was an array, then you made it a string, then wrapped it in quotes for some reason, and after all the manipulations you try to feed all this shit to the whereIn method, which expects an array from you, not a string
<?php
/**
* Вот тут было так, в этом месте у тебя массив превратился в строку
* $body_type = implode("','",$body_type);
*/
$body_type_string = implode("','",$body_type);
/**
* Далее эту же строку поместил в кавычки. Наверное для пущей надежности
* $body_type = "'".$body_type."'";
*/
echo $body_type_string;
$poisks = DB::table('items')
->where('brand',$brand)
->where('location',$location)
->where('fuel_type',$fuel_type)
->whereBetween('price', [$price_from, $price_to])
->whereIn('body_type', $body_type)
->whereIn('model', ['100','80','q5','a1'])
->orderBy('id', 'asc')
->paginate(5);
dd($poisks);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question