title: laravel eloquent where clause with pivot
body: <p>i have three table like below : </p>
  
  <pre><code>members
  ---------
  id | tag | hasOn
  1  |  1  |   1
  2  |  2  |   1
  3  |  3  |   0
  4  |  1  |   1
  
  tags
  ---------
  id | title | date
  1  |   a   |   05.12.2017 00:00:00
  2  |   b   |   01.12.2017 00:00:00
  3  |   c   |   12.11.2017 00:00:00
  4  |   d   |   27.11.2017 00:00:00
  </code></pre>
  
  <p>and has a pivot table</p>
  
  <pre><code>member_tag
  -------------
  member_id | tag_id | tagActive
      1     |    1   |    1
      1     |    2   |    1
      1     |    3   |    0
      1     |    4   |    1
      2     |    1   |    1
      2     |    2   |    1
      2     |    3   |    1
      2     |    4   |    1
  </code></pre>
  
  <p>this is my code ( Auth::user referred to Member Model )</p>
  
  <blockquote>
    <p>Auth::user()->tags()->where('date', '&lt;', \Carbon\Carbon::now())->orWhere(function($q){
        $q->wherePivot('tagActive', 1);
    })->first();</p>
  </blockquote>
  
  <p>it is not working.
  i have to checkout member tags by "date &lt; now" or "tagActive = 1"</p>
  
  <blockquote>
    <p>how could i do this? ( check it out where to own table column or where to pivot table column)</p>
  </blockquote>