title: Invalid argument supplied for foreach() in Laravel 5.1
body: <p>Everything was working fine and I don't know what happened. I'm getting this error:</p>
  
  <blockquote>
    <p>Invalid argument supplied for foreach().</p>
  </blockquote>
  
  <p>I'm trying to get tags that are attached to post like this <code>@foreach($post-&gt;tags as $tag)</code> If I do <code>var_dump</code> then it says <code>string(0)""</code> if I do this with <code>@if(is_array($post-&gt;tags))</code> - no error and no tags. I don't know where the problem is because the categories are made in the same principle and they are working fine. </p>
  
  <p>This is Post.php model code:</p>
  
  <pre><code>public function tags()
  {
      return $this-&gt;belongsToMany('App\Tag');
  }
  
  public function getTagListAttribute()
  {
      return $this-&gt;tags-&gt;lists('id')-&gt;all();
  }
  </code></pre>
  
  <p>This is Tag.php model code:</p>
  
  <pre><code>public function post()
  {
      return $this-&gt;belongsToMany('App\Post');
  }
  </code></pre>