I just discovered Laravel Scout and I wanted to make a search with where clausure. The code shown below
$notes = Note::search($request->lecturer_search)->where([
['course_id','=',$course_id],
['course_code_number', '=', $request->course_code_number_search]
])->orderBy('created_at','desc')->paginate(5);
But I'm getting this error:
Type error: Too few arguments to function Laravel\Scout\Builder::where(), 1 passed in /home/vagrant/www/Bee/app/Http/Controllers/SearchController.php on line 36 and exactly 2 expected
When I remove where clausure, there is no problem.
Scout has it's own where() method which accepts just two parameters: field and value. So do this:
->where('course_id', $course_id)
->where('course_code_number', $request->course_code_number_search)
Instead of this:
->where([
['course_id','=',$course_id],
['course_code_number', '=', $request->course_code_number_search]
])
You can look at the source code of the where() method here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With