switched to Eloquent, added group function