Laravel Query Builder WHERE NOT IN with multiple WHERE clause
<p>I have following query,</p>

<pre><code>SELECT * FROM `users` WHERE approved='1' 
and users.id NOT IN (SELECT donations.user_id FROM donations where month='1' 
and year='2016');
</code></pre>

<p>I have followed <a href="https://stackoverflow.com/questions/28361461/laravel-query-builder-where-not-in">Laravel Query Builder WHERE NOT IN</a>
and converted my query like this,</p>

<pre><code>$users = DB::table('users')-&gt;where('approved','=',1)-&gt;whereNotIn('id', function($q){
        $q-&gt;select('user_id')-&gt;from('donations')-&gt;where('month','=','$month')-&gt;where('year','=','$year');
        })-&gt;get();
</code></pre>

<p>But its not working, can anybody help me out where i am making mistake.
how can I convert it into Laravel query builder format?
Thanks.</p>