I have these table
- users table
id name password
- keywords table
id name user_id
- groups table
id name keyword_id
I want to retrieve logged in user groups
$groups = Group::with(['keyword' => function($query){
$query->where('user_id' , Auth::user()->id)
}]);
but all groups return NOT that groups for that user.
You should use
whereHas