title: Loop through relationships Laravel
body: <p>Stackoverflow, </p>
  
  <p>What I want to accomplish:</p>
  
  <p>I want to Loop through the database to find all the (Heroes) with their related (Interview). I want to also pull each Interview with it's related (Story) and (Image). So far I can dd($heroes) and I can see the array correctly grab each hero with their interview and each interview has it's associated image and story. How do I loop through this correctly?</p>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Invalid argument supplied for foreach() (View: /Users/plastics1509moore/Desktop/elephant_gin/resources/views/administration/index.blade.php)
  </code></pre>
  
  <p>This is what I have done:</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>$heroes = Hero::with('Interview', 'Interview.stories', 'Interview.images')-&gt;orderBy('position', 'asc')-&gt;get();
  </code></pre>
  
  <p><strong>Model Relationships:</strong></p>
  
  <p><strong>Hero:</strong></p>
  
  <pre><code>public function Interview()
  {
      return $this-&gt;hasOne('App\Interview', 'heroInt_id');
  }
  </code></pre>
  
  <p><strong>Interview:</strong></p>
  
  <pre><code>    public function relationships()
  {
      return $this-&gt;belongsTo('App\Hero');
  }
  public function stories()
  {
      return $this-&gt;hasMany('App\InterviewStory');
  }
  public function images()
  {
      return $this-&gt;hasMany('App\InterviewImage');
  }
  </code></pre>
  
  <p><strong>InterviewImage:</strong></p>
  
  <pre><code> public function relationships()
  {
      return $this-&gt;belongsTo('App\Interview');
  }
  </code></pre>
  
  <p><strong>InterviewStory</strong></p>
  
  <pre><code>public function relationships()
  {
      return $this-&gt;belongsTo('App\Interview');
  }
  </code></pre>
  
  <p><strong>Html:</strong></p>
  
  <p><strong>Loop:</strong></p>
  
  <pre><code>    @foreach($heroes as $hero)
         @foreach($hero-&gt;Interview as $story)
           &lt;div&gt;{{$story-&gt;id}}&lt;/div&gt;
          @endforeach    
      @endforeach
  </code></pre>