Error ErrorException: Undefined variable: request in file always appears, even though I have defined it as below
public function postlog_show(Re
you will have to use
$request
variable in whereHas
function, like I've shown
public function postlog_show(Request $request)
{
$log = $request->log;
$userlocation = Auth::user()->location;
$postlocations = Postlocation::orderBy('id', 'DESC')->where('location', $userlocation)
->whereHas('postlognya', function (Builder $query) use($request){
$query->where('log', 'like', '%' . $request->log . '%');
})
->get();
return view('front.postlog2')
->with('postlocations', $postlocations)
;
}