title: accessing collections within collections laravel 5
body: <p>I have a table of "rosters" that's pretty much strictly foreign keys. It acceses the "schools" table, "courses" table, and "students" table. So essentially, a 'student' takes a 'course' at a 'school'. My RostersController has this</p>
  
  <pre><code>public function show($id)
  {
     $roster = Roster::where('course_id', $id);
     return view('roster')-&gt;with('roster', $roster);
  }
  </code></pre>
  
  <p>My Roster Model is:</p>
  
  <pre><code>public function students()
  {
     return $this-&gt;hasMany('App\Student');
  }
  </code></pre>
  
  <p>My student Model is:</p>
  
  <pre><code>public function roster()
  {
    return $this-&gt;belongsTo('App\Roster');
  }
  </code></pre>
  
  <p>my view is this:</p>
  
  <pre><code>@foreach ($roster as $child)
    &lt;p&gt;{{$child-&gt;id}}&lt;/p&gt;
    &lt;p&gt;{{$child-&gt;students-&gt;first_name}}&lt;/p&gt;
  @endforeach
  </code></pre>
  
  <p>The rosters table just saves the student_id rather than all of the student's data that is already in the 'students' table. So i'm trying to access the students table from this relation but when i run this, it tells me that anything related to the students table is 'not on this collection'. I know that I could do things this way if i was working with a hasOne relationship, but how can i accomplish this with a hasMany to output the students table value in each row?</p>