Level 104
->where(function ($builder) {
$builder->where('is_visible_at', '<=', Carbon::now())
->orWhereNull('is_visible_at');
})
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
Is it possible to use the where query with multiple conditions ?
For example I want to query the list of the challenges only if is_visible_at <= Carbon::now() or if is_visible_at = null.
I have tried with where()->orWhere(), but it doesn't work.
Thanks for your answer.
Vincent
Model::where(function ($q) {
$q->where('is_visible_at ','<=',Carbon::now())->orWhere('is_visible_at ', null);
})->get();
Please or to participate in this conversation.