I am trying to filter my results. For this i have following query:
$destinations = $request['destinations'];
if($request->has('destinations'))
{
$trips = Trip::where('status','=',1)->whereHas('destinations', function($q) {
$q->where('destinationsid', '=', $destinations);
})->get();
}else{
echo "No destination provided";
}
But I'm getting undefined variable $destinations. If i replace $destinations with any id (6) it shows results. I have also tried to echo $destinations outside the query, it is returning array. What is wrong here? Can anyone help me?