title: Undefined variable: events
body: <p>This is my <code>routes/web.php</code></p>
  
  <pre><code>Route::get('/', function () {
       $events = App\Event::all();
       return view('events.index')-&gt;withEvent($events);
  });
  </code></pre>
  
  <p>And this my view file: <strong><em>index.blade.php</em></strong></p>
  
  <pre><code>&lt;body&gt;
      &lt;h1&gt;{{ count($events) }} Events&lt;/h1&gt;
  
      @foreach($events as $event)
          &lt;article&gt;
              &lt;h1&gt;{{ $event-&gt;name }}&lt;/h1&gt;
              &lt;p&gt;{{ $event-&gt;description }}&lt;/p&gt;
              &lt;p&gt;{{ $event-&gt;price }} euros&lt;/p&gt;
              &lt;p&gt;Lieu :{{ $event-&gt;location }}&lt;/p&gt;
          &lt;/article&gt;
          &lt;hr&gt;
      @endforeach
  &lt;/body&gt;
  </code></pre>
  
  <p>I got this error during run time:    </p>
  
  <blockquote>
    <p>Undefined variable: events (View:
    /home/pangraf/events/resources/views/events/index.blade.php)</p>
  </blockquote>