I am trying to get time availability for my scheduling system. I know how to do it with plain SQL query but I am having trouble translating the query to Laravel Eloquent. My query is like the one below
$query = "SELECT * FROM schedules WHERE (time_start BETWEEN '$start_datetime' AND '$end_datetime') OR (time_endBETWEEN '$start_datetime' AND '$end_datetime')";
and here's what I have tried with laravel eloquent so far
$sch = DB::table('schedules')
->where(function ($query) {
$query->whereBetween('time_start', [$start_datetime, $end_datetime]);
})
->orWhere(function($query){
$query->whereBetween('time_end', [$start_datetime, $end_datetime]);
})->get();
any ideas how to do it right? I am getting an error with my laravel eloquent query Undefined variable: start_datetime
Thanks