Level 27
You should be able to use orWhere: https://laravel.com/docs/7.x/queries#where-clauses
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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();
Please or to participate in this conversation.