I'd like to run different ->where() condition based to id.
Example what I'm trying to do:
I have joined activity table to interests table and based to ID I'd like to run different where condition.
->when('activity.id' <= '214469112', function ($q) {
return $q->where('interests.type', 'regular');
}, function ($q) {
return $q->where('activity.main', 1);
})->get();
However ->when() does not seem to respect <= => greater than or less than and returns always false so the return $q->where('activity.main', 1); is always used.
Any ideas how I could achieve different ->where() condition based to greater or less than with activity.id?
Sigh, sometimes one just tries to overcomplicate the problem.
Did this by using:
Where('id', '>', int)->where('condition1')->orWhere('id', '<=', int)->where('condition2')->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With