The current Model filters covers almost all of the uses cases.
Except it doesn’t work when you need to use: IS NULL or IS NOT NULL.
In EE2 you had to use an unescaped where() to get it done.
Same goes for BETWEEN.
Note: In my research i found filterGroup(), which is not documented. It’s super handy when you need a nested where clause.
ee('Model')->get('subs:Sub')->filter('status', 'IN', array('active', 'past_due', 'trialing'))
->filterGroup()
->filter('next_billing_at', '<', $date)
->orFilter('expires_at', '<', $date)
->endFilterGroup()
->batch(20, function($subs) {
// Loop over the current batch
foreach ($subs as $num => $sub)
{
// Do your thing
}
});
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.