I did not rework your data, but giving another example:
$quy = Powner::query()->leftJoin('dc_pets', 'dc_powners.ownerid', '=', 'dc_pets.ownerid')
->select('dc_powners.ownerid', 'dc_powners.oname')
->selectRaw('count(dc_pets.petid) as countOfPets')
->groupby('dc_powners.ownerid')
->orderby('dc_powners.oname')
->get();
Results basically give:
ownerid, oname, countOfPets
Like:
5|Bob|3
4|Greg|9
2|Rob|1
Notice the oname column, I had to tell the query to show it.
->select('dc_powners.ownerid', 'dc_powners.oname')
->selectRaw('count(dc_pets.petid) as countOfPets')
notice the regular select,
then came the aggregate raw select
Play with the order of statements they matter. And use an eloquent query, not query builder, they seem to do better for me.
https://laravel.com/docs/5.8/queries
https://laravel.com/docs/5.8/eloquent
https://laravel.com/docs/5.8/eloquent-relationships
I'd suggest viewing some videos on some of these various topics.
And or actually work the examples Taylor provides in the documentation.
Also even if eloquent can't handle a certain complex query, you can also write normal queries in laravel.
And you can query a query:
https://laracasts.com/discuss/channels/eloquent/calculate-average-of-multiple-fields-eloquent
And here is a good example of DB Facade usage:
https://laracasts.com/discuss/channels/laravel/sql-native-to-query-builder