I have the following query:
Item::select([\'items.id\', \'inventory.quantity\'])
->leftJoin(\'inventory\', \'items.id\', \'=\', \'inventory.item_id\')
If you only need the correct number of rows from a grouped result, and you don't care that much about the performance then you can call get() first and then call count() on that.
$count = Item::select(['items.id', 'inventory.quantity'])
->leftJoin('inventory', 'items.id', '=', 'inventory.item_id')
->groupBy('items.id')
->get()
->count();