Laravel / Cannot access protected property Illuminate\Database\Eloquent\Collection::$items
<p>I'm still learning Laravel and I'm using eloquent to run my queries. In my application a user can belong to one circle. The circle contains repositories, which in turn contains items. I am trying to fetch all of the items which belong to various repositories within one circle. </p>

<p>User Model:</p>

<pre><code>public function circle () {
  return $this-&gt;belongsTo('App\Models\Circle');
}
</code></pre>

<p>Circle Model:</p>

<pre><code>public function users () {
  return $this-&gt;hasMany('App\Models\User');
}

public function repositories () {
  return $this-&gt;hasMany('App\Models\Repository');
}
</code></pre>

<p>Repository Model:</p>

<pre><code>public function items () {
  return $this-&gt;hasMany('App\Models\Item');
}

public function circle () {
  return $this-&gt;belongsTo('App\Models\Circle');
}
</code></pre>

<p>Item Model:</p>

<pre><code>public function repository () {
  return $this-&gt;belongsTo('App\Models\Repository');
}
</code></pre>

<p>Here is the markup where I am trying to iterate over all items:</p>

<pre><code>  @foreach($items as $item)
      &lt;span&gt;{{ $item-&gt;name }}&lt;/span&gt;
  @endforeach
</code></pre>

<p>My controller responsible for handling the route is here:</p>

<pre><code>function library () {
  $user = Auth::user();
  $circle = $user-&gt;circle;
  $repositories = $circle-&gt;repositories;
  $items = $repositories-&gt;items;
  return View('pages.library', compact(['user', 'circle', 'items']));
}
</code></pre>

<p>As of right now I can retrieve 2 repositories belonging to a circle but I cannot retrieve the multiple items that belong to those 2 repositories. I have tried a @foreach on the repositories to run through both and push the items in an empty array but I only end up with the last item. Is there a query technique/step that I'm missing?</p>