I've some problem with eloquent relations ,what i want to do :
Ex : I've 3 tables
User(id,country_id,username) , Country(id,name), Post(id,user_id,content)
I want the list only of countries which have posts , is there a way to do that with Eloquent relations ?
the same of :
SELECT * FROM country
JOIN user ON country.id = user.country_id
JOIN post ON user.id = post.user_id
GROUP BY country.id
But i've an other problem now ,
i've a Trait global scope on the post model to add globally where conditions,
when i put the global scope the returned collection is empty although the BDD request i see in the debugger is right (i tried directly in mysql).
If you are getting the data you expect without the global scope you can remove the global scope for this specific query by using the withoutGlobalScopes method. Look for 'Removing Global Scopes' in this section of the docs.