This query:
$ids = EnergyMeters::leftJoin('meteringpoint_energymeter_relation', 'energymeter.id', '=',
'meteringpoint_energymeter_relation.meterId')
->where('id', '=', $meterPointId)
->where('Deleted', '=', '0')
->select('energymeter.id')
->orderBy('name')
->get();
gives me some ids as a result (structured as key, val)
[{"id":"03cd0c39-a51c-41a0-bbe3-37ae641d051e"},{"id":"0ebf61e7-b751-4931-b737-d8f71297e499"}, {"id"}, '...']
However I only need the ids as an array for this new sum-query:
Data::select(array(DB::RAW('sum(v1) as sumV1', 'sum(v2) as sumV2')))
->whereIn('id', $ids)
->where('PointOfTime', '>', $from)
->where('PointOfTime', '<=', $to + 86400)
->get();
Any eloquent solutions for this? Otherwise I would loop over the key and val array and push they value to a new array. Not that smart?
// edited the question to make it more clear