Laravel Eloquent: Get current id from inner function
<p>I know, we can do this in the controller:</p>

<pre><code>User::with('post')-&gt;get();
</code></pre>

<p>It will get every user's post from the database, based on <code>users.id</code>.
But the problem is, I want to do this:</p>

<pre><code>User::with(['post' =&gt; function($query) {
    # Throw users.id here...
}])-&gt;get();
</code></pre>

<p>How to do that?</p>