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

vincent15000's avatar

Where query with multiple conditions ?

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

0 likes
3 replies
tykus's avatar
->where(function ($builder) {
	$builder->where('is_visible_at', '<=', Carbon::now())
		->orWhereNull('is_visible_at');
})
gitwithravish's avatar
Level 16

@vincent15000

Model::where(function ($q) {
    $q->where('is_visible_at ','<=',Carbon::now())->orWhere('is_visible_at ', null);
})->get();
1 like

Please or to participate in this conversation.