I am developing a project with laravel 5.2 . But now I have a problem, In my databases, there are two tables users and comments. users table contains id, email, username, password, created_at, updated_atcolumns. comments table contains id, user_id, content, created_at, updated_at, deleted_at. Now in my code, I have an array which contains some comment id. I want to get users who owns these comments. So here is my code:
$commentIds = [
....
...
...
];
$users = User::whereHas('comments',function($query)use($commentIds){
$query->whereIn('id',$commentIds);
});
But I get exception said that column id is ambiguous.