Here is a sample of a complicated query that includes where and with and inner queries. This snuppet is the one used to get the legislative event stream on the dashboard in the GovIQ project.
Some time, you may need to get a record with some relationship and at the same time you need to get an inner relationship to that relationship and so forth. Here is the key : $records->with(['bill', 'bill.sponsor', 'bill.sponsorSenator', 'bill.sponsor.actions']).