Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Loomix's avatar

Get Events which overlap with FullCalendar View start and end Date

I need a little help regarding the syntax of Eloquent. I want to add more where clauses but can't get the OR working.

Works:

$events = DB::table('events')->select('id','resourceId','title','start','end')
  ->whereDate('start', '>=', $start)->whereDate('end', '<=', $end)->get();

Does not work:

$events = DB::table('events')->select('id','resourceId','title','start','end')
  ->whereDate('start', '>=', $start)->whereDate('end', '<=', $end) OR
  ->whereDate('start', '<=', $start)->whereDate('end', '>=', $end)->get();
0 likes
4 replies
Loomix's avatar

No luck so far with

$events = DB::table('events')->select('id','resourceId','title','start','end')
  ->whereDate('start', '>=', $start)->whereDate('end', '<=', $end)
  ->orWhere(function($query) {
    $query->whereDate('start', '<=', $start)
                 ->whereDate('end', '>=', $end);
    })
  ->get();

Is orWherenot supposed to work with whereDate?

Loomix's avatar

500 : Internal Server Error ...it's an invalid query.

Please or to participate in this conversation.