Hello!
I recently worked on a project with a similar task. My query for checking overlappings was big so I thought how to reduce it. After some time of analysis it became very simple, and lgical.
User::whereNotHas('availabilities', function($q)use($selected_date_time)
{
$q->where('unavailable_start_date', '<', $selected_date_time)
->where('unavailable_end_date', '>', $selected_date_time)
;
})
->with('availabilities')
->get();
I'm not sure if there is a whereNotHas method, but it would work. Your query would return all users except those who have all availabilities unavailable.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community