Having trouble trying to use the with statement on a query as shown here
thePage::select('field1','field2')
->with('pagePhotos')
This query works fine, but what if I want to only get pagePhotos where the photoLocation="Miami". This photoLocation field is not on thePage Model, and only on the pagePhotos table.
Below is a stab in the dark that doesn't work but it shows the logic I'm trying to get at, I hope!
thePage::select('field1','field2')
->with(
'pagePhotos'->where('photoLocation','=','Miami')
)->get();
EDIT
In addition to the answer / comments here I found this helped me get the query perfect https://stackoverflow.com/a/41436703/7675570
Just in case anyone has similar scenarios it could help.