title: Laravel unique validation with where and join
body: <p>I'm trying to add aditional where clause in the unique validation rule. But before that, i need a join with other table. But I'm not being successful.</p>
  <p>I have 2 Tables:</p>
  <h2>teams</h2>
  <p>with id, and name field</p>
  <h2>role_user_team</h2>
  <p>with role_id, user_id, and team_id being this three the key.</p>
  <p>So i need to check if the teams.name field is unique for one specific user.
  I did try this:</p>
  <pre><code>'name' =&gt; Rule::unique('teams')-&gt;where(function ($query){
      //return $query-&gt;where('account_id', 1);
      return $query-&gt;join('role_user', 'role_user.team_id', '=', 'teams.id')-&gt;where('role_user', Auth::user()-&gt;id);
            });
  </code></pre>
  <p>I know the problem is with the join but i don´t know how to solve it.
  Thank you!</p>