I have the following query:
Item::select([\'items.id\', \'inventory.quantity\'])
->leftJoin(\'inventory\', \'items.id\', \'=\', \'inventory.item_id\')
Yes, count returns only 1 row, always.
You would probably want:
Item::select(['items.id as id', 'inventory.quantity as quantity'])
->leftJoin('inventory', 'items.id', '=', 'inventory.item_id')
->groupBy('items.id')
->lists('quantity', 'id');
this will return an array with id as keys, and quantity as values. Otherwise use get, but never count if you want grouped results.