Get all rows except any models already related
<p>So I have 2 models in Laravel 5.3.  <code>Practice</code> and <code>Offer</code>, they have a many to many relationship which is set up and working.  I can attach offers to practices etc.  I want to retrieve all offers that are not already related to the practice.</p>

<p>The logged in user also belongs to the practice with <code>practice_id</code>.</p>

<p>In my controller I am passing in <code>$offer</code> in the constructor which just relates to all offers.  I've tried using the <code>reject()</code> method as below but I'm getting nothing back, and I can't figure it out.</p>

<p>If I use <code>$this-&gt;offer</code> I get everything.</p>

<pre><code>$query = $this-&gt;offer-&gt;reject(function($offer){
    return $offer-&gt;whereHas('practices', function($q) {
        return $q-&gt;where('practice_id', Auth::user()-&gt;practice_id);
    });
});
</code></pre>

<h1>Releations</h1>

<h3>User Model</h3>

<pre><code>public function practice()
{
    return $this-&gt;belongsTo(Practice::class);
}
</code></pre>

<h3>Practice Model</h3>

<pre><code>public function users()
{
    return $this-&gt;hasMany(User::class, 'practice_id');
}

public function offers()
{
    return $this-&gt;belongsToMany(Offer::class, 'offer_practice')-&gt;withTimestamps();
}
</code></pre>

<h3>Offer Model</h3>

<pre><code>public function practices()
{
    return $this-&gt;belongsToMany(Practice::class, 'offer_practice')-&gt;withTimestamps();
}
</code></pre>

<p>Please help.</p>