I love the new Model service, but I’m wondering how I would add a groupby statement when using it? I’m working on some custom code for an addon for a client who has channel entries that sometimes need to be grouped by the value in a custom field.
I’ve been able to do this on the front end in the templates by forking and updating the Group By extension, but I’d also like to be able to do this when fetching from the ChannelEntry Model in an addon – something like the example below, but with grouping the returned values on field_id_15
I’m not seeing any way to do that in the documentation other than using the Legacy Database Driver. Can it be done?
$entries = ee('Model')->get('ChannelEntry') ->fields('entry_id','field_id_15','entry_date') ->filter('status','open') ->filter('field_id_15','IN',array('apples','oranges','bananas','kiwi','chayote','rambutan','etc.')) ->filter('channel_id',4) ->limit(25) ->order('field_id_15','ASC') ->all();