I would suggest working some of the examples in the docs.
And the from scratch video series he covers more basic crud as well.
And you could use that query as is
https://laracasts.com/discuss/channels/laravel/sql-native-to-query-builder
Also I just gave a quick answer a while back to someone looking for join and group by together.
This is just an 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
// more