title: Laravel Collection - Condition in belongsToMany relationship with whereHas equivalent
body: <p>I've 3 tables:</p>
  <p>Users:</p>
  <pre><code>Schema::create('users', function (Blueprint $table) {
      $table-&gt;unsignedInteger('id')-&gt;unique();
      $table-&gt;string('name', 50)-&gt;nullable();
      $table-&gt;timestamps();
  });
  </code></pre>
  <p>Conversations:</p>
  <pre><code>Schema::create('conversations', function (Blueprint $table) {
      $table-&gt;bigIncrements('id');
      $table-&gt;string('token', 50)-&gt;nullable();
      $table-&gt;timestamps();
  });
  </code></pre>
  <p>And User_Conversation:</p>
  <pre><code>Schema::create('conversation_user', function (Blueprint $table) {
      $table-&gt;unsignedInteger('conversation_id');
      $table-&gt;unsignedInteger('user_id');
      $table-&gt;dateTime('read_at')-&gt;nullable();
  });
  </code></pre>
  <p>One conversation can have 2 users.</p>
  <p>I have this class for Users:</p>
  <pre><code>class User extends Model {
      public function conversations(){
          return $this-&gt;belongsToMany(Conversation::class, 'conversation_user', 'user_id', 'conversation_id');
      }
  
      public function getConversationWith($user_id){
          return $this-&gt;conversations()-&gt;whereHas('users', function ($q) use ($user_id) {
              $q-&gt;where('ml_users.user_id', $user_id);
          })-&gt;first();
      }
  }
  </code></pre>
  <p>My problem: I need to change the <strong>getConversationWith()</strong> method to:</p>
  <pre><code>public function getConversationWith($user_id){
      return $this-&gt;conversations-&gt;where('users.user_id', $user_id)-&gt;first();
      // Or this
      return $this-&gt;conversations-&gt;whereIn('users.user_id', [$this-&gt;id, $user_id])-&gt;first();
  }
  </code></pre>
  <p>To get conversations with given user_id.</p>
  <p><strong>Is there a way to do this with collections ?</strong></p>
  <p>Thank in advance</p>