title: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous Laravel whereHas returning error
body: <p>Hello I want to filter my response by tags and categories in laravel 9. my code is :</p>
  <pre><code>$posts = Post::when($categoryId &gt; 0, function($query) use ($categoryId) {
              return $query-&gt;where('category_id', '=', $categoryId);
          })
          -&gt;when($tagId &gt; 0, function($query) use ($tagId){
              return $query-&gt;whereHas('tags', function($query) use ($tagId) {
                  return $query-&gt;where('id', $tagId);
              });
          })
          -&gt;get();
  
          return view('blog::posts.index', compact('posts', 'categories'));
  </code></pre>
  <p>but i got this error :
  SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous</p>
  <pre><code>select * from `posts` where exists (select * from `tags` inner join `post_tag` on `tags`.`id` = `post_tag`.`tag_id` where `posts`.`id` = `post_tag`.`post_id` and `id` = 4)
  </code></pre>