title: Laravel Authentication additional conditions with another model
body: <p>Using Laravel's 5.2 Authentication, the docs show that I can add more conditions to an authentication query like so:</p>
  
  <p><strong>Specifying Additional Conditions</strong></p>
  
  <p>If you wish, you also may add extra conditions to the authentication query in addition to the user's e-mail and password. For example, we may verify that user is marked as "active":</p>
  
  <pre><code>if (Auth::attempt(['email' =&gt; $email, 'password' =&gt; $password, 'active' =&gt; 1])) {
      // The user is active, not suspended, and exists.
  }
  </code></pre>
  
  <p>In my case, I would like to set a condition which lives in another many-to-many Eloquent Model:</p>
  
  <pre><code>class Account extends Model
  {
      public function users() {
          return $this-&gt;belongsToMany('App\User', 'account_users');
      }
  }
  class User extends Model implements AuthenticatableContract
  {
      public function accounts() {
          return $this-&gt;belongsToMany('App\Account', 'account_users');
      }
  }
  </code></pre>
  
  <p>There's an account <code>id</code> which is passed though a middleware and I access it like this:</p>
  
  <p><code>$request-&gt;account</code></p>
  
  <p>How do I implement the new condition when it refers to a related model? I just don't know how to make use of the ORM relationship. Any help pointing in the right direction is much appreciated!</p>