title: ErrorException Invalid argument supplied for foreach() Laravel
body: <p>I'm just trying to get all the data from my table name posts but an error occur it wont let me display the data on my index.blade.php</p>
  
  <pre><code>public function index()
      {
          //
          $posts = Post::all();
  
          return view('posts.index')-&gt;withPosts('$posts');
  
      }
  </code></pre>
  
  <p>and here's my index.blade.php</p>
  
  <pre><code>@foreach( $posts as $post )
              &lt;div class="post-preview"&gt;
                      &lt;a href="post.html"&gt;
                          &lt;h2 class="post-title"&gt;
  
                              {{ $post-&gt;title }} -&gt; this is the one i want to display
  
                          &lt;/h2&gt;
                          &lt;h3 class="post-subtitle"&gt;
  
                              {{ $post-&gt;body }}
  
                          &lt;/h3&gt;
                      &lt;/a&gt;
                      &lt;p class="post-meta"&gt;Posted by &lt;a href="#"&gt;Start Bootstrap&lt;/a&gt; on September 24, 2014&lt;/p&gt;
                      &lt;button type="button" class="btn btn-secondary"&gt;&amp;nbsp;&amp;nbsp;Edit&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/button&gt;
                      &lt;button type="button" class="btn btn-secondary"&gt;Delete&lt;/button&gt;
              &lt;/div&gt;
  
                  &lt;hr&gt;
              @endforeach
  </code></pre>