Level 53
You are using an anonymous function in there (in the join part) PHP Scopes will limit the visibility of any variable to the scope where it was declared ($duration was declared outside of that function)
You can tell the function to use the $duration variable like this:
$duration = 1;
$rooms = Room::Available($start,$end)
->where('pax', '=', $data['pax'])
->where('location','=',$data['location']) // Search in base alla sede
->join('prices', function ($join) use ($duration) {
$join->on('rooms.id','=','prices.room_id')
->where('prices.duration', '=', $duration);
})->get();
1 like