Active record converts to Normal sql and uses pdo with bindings at runtime.
Meaning an eloquent query is converted right back to the above.
See: https://laracasts.com/discuss/channels/laravel/sql-native-to-query-builder
And use proper bindings. But basically an eloquent query is just "built up" with some "trial and error" like any query, something like:
$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
https://laravel.com/docs/5.8/queries
But if you have a good working query above, I'd use as is with the db facade, or getPdo().