Eloquent can use query builder methods. However there are eloquent relation queries and eloquent queries.
A relation query is always at least two queries. Like a one to many, in the background two queries are performed.
- a query to get parent
- a query to get child (related) records
So in query builder you can write two queries.
But just curious, why not set up relations.
Edit: Query builder doesn't have a ->toArray(); You can map, see https://laracasts.com/discuss/channels/guides/to-array
And an example (not your data) of an eloquent query using query builder techniques:
$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
Just test data and getting the count of a owners pets: In example:
Greg has 9 pets in the related table.