Closed
Description
I've been going round in circles a bit here - hoping someone can help or tell me what I'm doing wrong!
This query works fine:
$query = \DB::connection('mongodb')
->collection('statistics')
->whereIn('vehicle.branch_id', $branchIds)
->select(['event', 'created_at', 'vehicle.vin'])
->get();
However, I want to use raw, in order to return a column with a different name, and also perform aggregations:
$query = \DB::connection('mongodb')
->collection('statistics')
->whereIn('vehicle.branch_id', $branchIds)
->select(['event', 'created_at', \DB::raw('vehicle.vin as vin'), \DB::raw('COUNT(*) as count')])
->get();
This always gives me an Illegal Offset type in Builder.php line 353, as it is expecting an array of column names, but it gets instances of Expression.
I've tried building this query a few different ways, but can't get past this issue.
Any ideas?
TIA, Jon
Metadata
Metadata
Assignees
Labels
No labels