laravel 5.2 query scope with join
<p>I want a list with all posts of users that are under the same subscription. So I have a subscription table, user table and post table.</p>

<p>Posts belongs to a user and users belong to a subscription.</p>

<p>I read on laravel.com that I can work with global query scopes.</p>

<p>SQL would be (I think):</p>

<pre><code>SELECT * FROM posts INNER JOIN users ON posts.user_id = users.id INNER JOIN subscriptions ON users.subscription_id = subscriptions.id WHERE subscriptions.id = $subscription_id_of_user_that_is_logged_in
</code></pre>

<p>What do I have to put in my scope file?</p>

<pre><code>public function apply(Builder $builder, Model $model) {
  return $builder-&gt;where(????);
}
</code></pre>

<p>Second question: is this a good way to 'hide' posts from other users of a different subscription?</p>