Developers, I'm doing a search function and I can not bring the variable into sql? can anyone help, my code:
public function search(Request $request){
{
$search = $request->input('q');
$grupo = Grupo::where('nome', 'like','%'.$request->input('q').'%')
->orWhere('sku','like','%'.$request->get('q').'%')->toSql();
// dd($request);
echo "My search string: ".$request->input('q');
echo "<br>";
echo "Query: ".$grupo;
//return view('anuncios')->with('grupos', $search);
}
the return in html:
My search string: oto
Query: select * from grupos
where nome
like ? or sku
like ?
any idea?
please refer to this link. [https://stackoverflow.com/questions/32372437/does-laravels-tosql-method-mask-ids-column-value-being-replaced-by-question]
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community