Laravel Eloquent choosing which model to find

I have a Player model that has homeAddress which has homeAddressPhoto, linked by foreign key.

I could get the list of home address photos by calling this:


Now I want to find the photos by homeAddressPhoto id, but the code below finds the photo by homeAddress id.


How should I write the where part to get the id from homeAddressPhoto instead of homeAddress?

1 answer

  • answered 2018-07-11 06:01 Jinal Somaiya

    try this: