A good link to look at: https://stackoverflow.com/questions/60559442/nested-orwhere-in-one-where-laravel
To implement the following SQL:
select * from logs where created_at between "2021-02-23" and "2021-02-28" ((id is not null and recording is not null) or (type="canceled" and worker is not null));
In Laravel:
$query = DB::table('logs as cl') ->whereBetween('cl.created_at', ["2021-02-23", "2021-02-28"]) ->where(function($q1) { $q1->where(function($q2){ $q2->whereNotNull('cl.id') ->whereNotNull('cl.recording'); })->orWhere(function($q2){ $q2->where('cl.type', 'canceled') ->whereNotNull('cl.worker'); }); }) ->get();
Basically, one function per parenthesis!